Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2045

Rules Fact Error In Complex Condition Structure

    XMLWordPrintable

    Details

      Description

      We are running into a complex production rule that either doesn't work or generate errors. I debugged and it seems Drools is not using the correct fact for some segments of the rule conditions. Steps to reproduce

      1. Build the attached test case
      2. Run the DroolsDefectTest junit test, it should print value "Worked!" on the output console.
      3. Modify the rule by remove the commented condition that uses variable b2.
      4. Run the test again.
      Expected result: the rule should output "Worked!" again.
      Actual result: failed with error:
      org.drools.RuntimeDroolsException: org.drools.test.Rule_test_0Eval4Invoker@68f1f17a : java.lang.NumberFormatException: For input string: "Y"
      at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:82)
      at org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:148)
      at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(SingleTupleSinkAdapter.java:20)
      at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:156)
      at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
      at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
      at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:299)
      at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
      at org.drools.reteoo.Rete.assertObject(Rete.java:175)
      at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
      at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
      at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:915)
      at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:887)
      at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:688)
      at com.firstbest.rules.DroolsDefectTest.test_drools(DroolsDefectTest.java:35)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: java.lang.NumberFormatException: For input string: "Y"
      at java.lang.NumberFormatException.forInputString(Unknown Source)
      at java.lang.Integer.parseInt(Unknown Source)
      at java.lang.Integer.valueOf(Unknown Source)
      at com.firstbest.rules.Field.intValue(Field.java:29)
      at org.drools.test.Rule_test_0.eval4(Rule_test_0.java:32)
      at org.drools.test.Rule_test_0Eval4Invoker.evaluate(Rule_test_0Eval4Invoker.java:20)
      at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:77)
      ... 32 more

        Attachments

          Activity

            People

            Assignee:
            tirelli Edson Tirelli
            Reporter:
            hchen_0 Hao Chen (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: