Hide Forgot
Description of problem: A ClassCastException comes up when using negative patterns without setting event processing mode to STREAM. This configuration does not really make sense, but a warning or an error indicating what the real problem is should be emitted, instead of a general CCE. The exception stacktrace: java.lang.ClassCastException: org.drools.core.reteoo.RuleTerminalNodeLeftTuple cannot be cast to org.drools.core.time.impl.DefaultJobHandle at org.drools.core.phreak.PhreakTimerNode.doLeftDeletes(PhreakTimerNode.java:154) at org.drools.core.phreak.PhreakTimerNode.doNode(PhreakTimerNode.java:59) at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:360) at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:162) at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:117) at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:205) at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:65) at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:936) at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1183) at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:936) at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:910) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:233) at org.drools.compiler.integrationtests.NegativePatternsTest.testSingleEvent(NegativePatternsTest.java:140) Version-Release number of selected component (if applicable): Drools 6.0.0-SNAPSHOT BRMS 6.0.0-ER2 How reproducible: Remove line 98: .setEventProcessingMode(EventProcessingOption.STREAM); in the org.drools.compiler.integrationtests.NegativePatternsTest class and run tests from this class.
It is not possible to raise a compilation error in this case because the EventProcessingMode is a KieBase option and then it is not available at compile time. What I did is to throw a RuntimeException when you try to create such a kieBase saying: java.lang.RuntimeException: The requested KieBase "KBase" has been set to run in CLOUD mode but requires features only available in STREAM mode I added a test case demonstrating this here: https://github.com/droolsjbpm/drools/blob/69dd8626bb40cd86dd59247a908aa8f212b5eb84/drools-compiler/src/test/java/org/drools/compiler/integrationtests/CepEspTest.java#L3210
Verified on BRMS 6.0.0.ER4.