[jboss-jira] [JBoss JIRA] (DROOLS-164) Rule do not fire when lock-on-active true present

Sergey Alaev (JIRA) jira-events at lists.jboss.org
Mon Jun 10 02:44:54 EDT 2013


    [ https://issues.jboss.org/browse/DROOLS-164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12780444#comment-12780444 ] 

Sergey Alaev commented on DROOLS-164:
-------------------------------------

Yes, those are the only rules. 

I was able to reproduce this error with custom model. See code below.

{code:title=Model classes}
public interface TestBooking {
    TestTrade getTrade();
}
public interface TestTrade extends TradeHeader {
    void setAction(String action);
}
{code}
{code:title=Instance creation (Groovy)}
        TestTrade trade = Proxy.newProxyInstance(TestTrade.class.classLoader, [TestTrade.class] as Class[], new InvocationHandler() {
            String action = null
            
            public Object invoke(Object proxy, Method method, Object[] args) {
                def result = doInvoke(proxy, method, args)
                println method.name + ': ' + (args as List) + " -> " + result
                return result
            }
            
            private Object doInvoke(Object proxy, Method method, Object[] args) {
                if (method.name == 'setAction') {
                    action = args[0]
                    return null
                }
                if (method.name == 'hashCode') {
                    return action == null ? 0 : 1
                }
                return null
            }
        })
        
        TestBooking tb = new TestBooking() {
            public TestTrade getTrade() {
                return trade
            }
        }
{code}
{code:title=Rules}
rule "Rule1"
salience 1
when
    $booking: TestBooking()
    $trade: TestTrade() from $booking.getTrade()
    not (String())
then
    $trade.setAction("New");
    modify($booking) {}
    insert ("run");
end;

rule "Rule2"
lock-on-active true
when
    $booking: TestBooking(  )
    $trade: Object( ) from $booking.getTrade()
then

end
{code}

{code:title=Test output(proxy invocations)}
hashCode: null -> 0
hashCode: null -> 0
hashCode: null -> 0
hashCode: null -> 0
hashCode: null -> 0
hashCode: null -> 0
setAction: [New] -> null
hashCode: null -> 1
hashCode: null -> 1
hashCode: null -> 1
hashCode: null -> 1
hashCode: null -> 1
hashCode: null -> 1
hashCode: null -> 1
hashCode: null -> 1
{code}



                
> Rule do not fire when lock-on-active true present
> -------------------------------------------------
>
>                 Key: DROOLS-164
>                 URL: https://issues.jboss.org/browse/DROOLS-164
>             Project: Drools
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 5.5.0.Final
>         Environment: Win7/64 Java6
>            Reporter: Sergey Alaev
>            Assignee: Mark Proctor
>
> Given following rules:
> 1  rule "Rule1"
> 2  salience 1
> 3  when
> 4      $booking: TradeBooking()
> 5      $trade: TradeHeader() from $booking.getTrade()
> 6      not (String())
> 7  then
> 8      $trade.setAction("New");
> 9      modify($booking) {}
> 10     insert ("run");
> 11 end;
> 12
> 13 rule "Rule2"
> 14 lock-on-active true
> 15 when
> 16     $booking: TradeBooking(  )
> 17     $trade: Object( ) from $booking.getTrade()
> 18 then
> 19     
> 20 end
> and instance of TradeBooking() object with booking.trade != null
> i expect to get: Rule1 fired, Rule2 fired
> but i get: Rule1 fired
> I can get expected result if i comment out one of the following lines: 2, 8, 9, 14
> I was unable to reproduce this issue using standard mutable class (java.util.Date), so there are some details:
> TradeBooking, TradeHeader are interfaces, instances are generated using JDK proxy.
> $booking.getTrade() returns JDK Proxy over interface that inherits TradeHeader.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list