[
https://issues.jboss.org/browse/DROOLS-9?page=com.atlassian.jira.plugin.s...
]
Andreas Bentele updated DROOLS-9:
---------------------------------
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
{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}
was:
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, 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:
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}
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
Security Level: Public(Everyone can see)
Reporter: Andreas Bentele
Assignee: Mark Proctor
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}
--
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