Details
-
Bug
-
Resolution: Won't Do
-
Major
-
None
-
None
-
None
-
None
-
-
High
Description
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
$service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID") > 0
- from this and rule semantics it follows that the next expression should never be evaluated, but the JIT compiler evaluates it:
service.getTimePerStroke($service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID")) > 15
- 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:
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
I think, it's a failure that the JIT compiler evaluates the line
service.getTimePerStroke($service.getLongValue(service.workplaceIdForMachineId($machineId, $actionTimestamp), "RC.WORKPLACE_LEADING_OPERATION_ID")) > 15
because the previous condition expression evaluates to false. Or do you think this behavior works as designed?
Attachments
Issue Links
- is duplicated by
-
DROOLS-39 A NPE occurs silently when execute a complex rule a lot of time
- Resolved