]
Mark Proctor reassigned JBRULES-2774:
-------------------------------------
Assignee: Edson Tirelli (was: Mark Proctor)
CCE when using undeclared events
---------------------------------
Key: JBRULES-2774
URL:
https://issues.jboss.org/browse/JBRULES-2774
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 5.1.1.FINAL
Reporter: Wolfgang Laun
Assignee: Edson Tirelli
Fix For: 5.2.0.CR1
It may not be possible to avoid a runtime error because the parser does not
"understand" temporal operators although it should not be impossible to add
this. But is should be possible to produce an error message that clearly indicates the
problem, e.g., "Cannot use operator xxx on fact type YYY which is not an event"
or "YYY must be declared with @role(event) when using temporal operators".
Omitting the declares for events, as in this DRL:
/**
declare CallStart
@role( event )
@timestamp( time )
end
declare CallEnd
@role( event )
@timestamp( time )
end
**/
rule "match-start-end"
when
$start: CallStart( $s: source, $d: destination, $st: time )
not CallStart( this before $start )
$end: CallEnd( source == $s, destination == $d, $et: time )
not CallEnd( source == $s, destination == $d, this before $end )
then
//...
end
results in a runtime exception:
Exception in thread "main" java.lang.ClassCastException:
org.drools.common.DefaultFactHandle cannot be cast to org.drools.common.EventFactHandle
at
org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedRight(BeforeEvaluatorDefinition.java:316)
at
org.drools.rule.VariableRestriction.isAllowedCachedRight(VariableRestriction.java:117)
at org.drools.rule.VariableConstraint.isAllowedCachedRight(VariableConstraint.java:121)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:151)
at org.drools.reteoo.NotNode.assertObject(NotNode.java:140)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1174)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1123)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
at call.Main.execute(Main.java:90)
at call.Main.main(Main.java:100)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: