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

ClassCastException upon unreferenced declare update

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • 7.38.0.Final
    • core engine
    • None
    • 2020 Week 25-27 (from Jun 15), 2020 Week 43-45 (from Okt 19)
    • Hide

      Run:

      mvn clean test

      on attached reproducer.

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

      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

              mfusco@redhat.com Mario Fusco
              mcasalino Matteo Casalino (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: