Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5449

ClassCastException upon unreferenced declare update

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Explained
    • Affects Version/s: 7.38.0.Final
    • Fix Version/s: None
    • Component/s: core engine
    • Labels:
      None
    • Sprint:
      2020 Week 25-27 (from Jun 15)
    • Steps to Reproduce:
      Hide

      Run:

      mvn clean test

      on attached reproducer.

      Show
      Run: mvn clean test on attached reproducer.
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      After updating a declared type that is not referenced in the rules with updateToVersion(),
      running fireAllRules() many times in a loop throws ClassCastException.

      E.g., when the following DRL:

      declare UnreferencedType
       x : int
      end 
      declare ReferencedType
       str : String
      end
       
      rule "example rule"
      when
       ReferencedType( str == "A" )
      then
      end

      is updated to:

      declare UnreferencedType
       x : int
       newField : String
      end 
      declare ReferencedType
       str : String
      end
       
      rule "example rule"
      when
       ReferencedType( str == "A" )
      then
      end

      the following exception it thrown by fireAllRules():

      java.lang.RuntimeException: Error evaluating constraint 'str == "A"' in [Rule "example rule" in org/example/rules.drl]
       at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:277)
       at org.drools.core.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:225)
       at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:139)
       ...
       Caused by: java.lang.ClassCastException: class org.example.ReferencedType cannot be cast to class org.example.ReferencedType (org.example.ReferencedType is in unnamed module of loader org.drools.dynamic.DynamicProjectClassLoader$DefaultInternalTypesClassLoader @46292372; org.example.ReferencedType is in unnamed module of loader org.drools.dynamic.DynamicProjectClassLoader$DefaultInternalTypesClassLoader @23b8d9f3)
       at ConditionEvaluator7ed8b2c57cad4e74b856fdba30554aa1.evaluate(Unknown Source)
       at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:275)
       ... 43 more

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mfusco Mario Fusco
                Reporter:
                mcasalino Matteo Casalino
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: