[jboss-jira] [JBoss JIRA] (DROOLS-9) Exception in User-defined Java method when rules are optimized by the JIT compiler
Sarf Khan (JIRA)
issues at jboss.org
Thu Sep 11 02:54:19 EDT 2014
[ https://issues.jboss.org/browse/DROOLS-9?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13001139#comment-13001139 ]
Sarf Khan commented on DROOLS-9:
--------------------------------
[~mfusco]
I'm new to drools and am facing a similar issue. I am not able to fully comprehend the comments given by you.
So I have few queries regarding mentioned exception.
1. Does this exception cause or halt the rule execution?
2. If yes, how to avoid it?
3. Do you recommend some changes in the expression?
My drools expression in application looks like this:
"(this.operator == 'BWH' && this.handlingExceptiondesc=='DLY' && $recTrnd.delay!=null && $recTrnd.delay > this.minVal && $recTrnd.delay <= this.maxVal)"
And the stack trace of the exception thrown is similar to the above stack trace. and it looks like
.....RecTrndFact.getDelay: target of method is null
at org.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:66)
at org.mvel2.optimizers.impl.refl.nodes.VariableAccessor.getValue(VariableAccessor.java:37)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)
at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:107)
at org.mvel2.ast.And.getReducedValueAccelerated(And.java:34)
at org.mvel2.ast.And.getReducedValueAccelerated(And.java:34)
at org.mvel2.ast.And.getReducedValueAccelerated(And.java:34)
at org.mvel2.ast.Or.getReducedValueAccelerated(Or.java:34)
at org.mvel2.ast.Or.getReducedValueAccelerated(Or.java:34)
at org.mvel2.ast.Or.getReducedValueAccelerated(Or.java:34)
at org.mvel2.ast.Or.getReducedValueAccelerated(Or.java:34)
at org.mvel2.ast.Or.getReducedValueAccelerated(Or.java:34)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
> Exception in User-defined Java method when rules are optimized by the JIT compiler
> -----------------------------------------------------------------------------------
>
> Key: DROOLS-9
> URL: https://issues.jboss.org/browse/DROOLS-9
> Project: Drools
> Issue Type: Bug
> Reporter: Andreas Bentele
> Assignee: Mario Fusco
> Attachments: DroolsJITTestCase.zip
>
>
> I watched this issue after upgrading from Drools 5.3.1 to Drools 5.5.0.Final.
> I didn't find any trivial example, so I reproduced the error with a non-trivial test case derived from a real-live rule, and attached the test case to this issue. The output is listed in the field "Steps to reproduce":
> What does the application:
> - it calls the rule "DroolsJITTest-Rule" 20 times - 20 is the threshold for jitting. In the output, you can see the line "Service.getAllTimers" 20 times.
> - after that output, a exception during jitting is thrown, because com.sample.Service.getTimePerStroke(Service.java:42) throwed an exception
> - this service is called in the LHS of the rule
> But:
> # in the rule, the following expression evaluates always to false, because service.getLongValue returns always 0
> {code}
> $service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID") > 0
> {code}
> # from this and rule semantics it follows that the next expression should never be evaluated, but the JIT compiler evaluates it:
> {code}
> service.getTimePerStroke($service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID")) > 15
> {code}
> # as we have seen in the bullet no. 1, the parameter of service.getTimePerStroke is 0. In com.sample.Service, Line 41 the parameter value is asserted to be not 0, so an RuntimeException is thrown (Line 42).
> Code of the rule:
> {code}
> rule "DroolsJITTest-Rule"
> when
> $service : Service()
> p: PulseEvent(
> $actionTimestamp : actionTimestamp,
> $eventTimestamp : eventTimestamp
> )
> t: TimerToken(
> $machineId : id,
> $timestampUTC : timestampUTC,
> $service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID") > 0,
> service.getTimePerStroke($service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID")) > 15
> ) from $service.getAllTimers("RC.MACHINE_STROKE_TIMER")
> then
> System.out.println( "Rule executed" );
> update(p);
> end
> {code}
> I think, it's a failure that the JIT compiler evaluates the line
> {code}
> service.getTimePerStroke($service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID")) > 15
> {code}
> because the previous condition expression evaluates to false. Or do you think this behavior works as designed?
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
More information about the jboss-jira
mailing list