[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2735) ClassCastException for casting DefaultFactHandle to EventFactHandle when using Sliding Windows

Will Lauer (JIRA) jira-events at lists.jboss.org
Fri Oct 15 12:34:40 EDT 2010


    [ https://jira.jboss.org/browse/JBRULES-2735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557395#action_12557395 ] 

Will Lauer commented on JBRULES-2735:
-------------------------------------

It looks like this is a problem with the handling of "from collect" when combined with event facts. When a rule with "from collect" is evaluated, it eventually calls RetooFactHandleFactory.newFactHandle(), passing in null for the ObjectTypeConf, making the factory assume that the fact to be constructed is a default fact type, not an event fact. The result is that facts inserted into a collection using "from collect" will have morphed their role. If these facts are later used in another clause in the rule (for example, through using the "from" clause on a rule) and temporal reasoning is applied to them, a type mismatch will occur and a casting exception will be generated.

Looks like the offending null is coming from FromNode.assertLeftTuple(). Here, a call is made to workingMemory.getFactHandleFactory().newFactHandle(...) with null being passed instead of the correct confType being looked up. There is a comment here indicating that the null is intentional. Seems like there is a disconnect here with the event functionality.

> ClassCastException for casting DefaultFactHandle to EventFactHandle when using Sliding Windows
> ----------------------------------------------------------------------------------------------
>
>                 Key: JBRULES-2735
>                 URL: https://jira.jboss.org/browse/JBRULES-2735
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core (fusion)
>    Affects Versions: 5.1.1.FINAL
>         Environment: Windows XP SP3, Java 1.6.0_21, Drools 5.1.1
>            Reporter: Will Lauer
>            Assignee: Mark Proctor
>
> When playing with a simple sliding window test using a single type of fact with @role(event), the following ClassCastException is generated:
> 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.evaluateCachedLeft(BeforeEvaluatorDefinition.java:333) 
>         at org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110) 
>         at org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115) 
>         at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:142) 
>         at org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274) 
>         at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138) 
>         at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189) 
>         at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64) 
>         at org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662) 
>         at org.drools.reteoo.AccumulateNode.assertLeftTuple(AccumulateNode.java:181) 
>         at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189) 
>         at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138) 
>         at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:148) 
>         at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59) 
>         at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145) 
>         at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450) 
>         at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:368) 
>         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 net.wlauer.DroolsEngine.NonSpringRulesEngine.main(NonSpringRulesEngine.java:71) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list