[jboss-jira] [JBoss JIRA] (DROOLS-5449) ClassCastException upon unreferenced declare update

Matteo Casalino (Jira) issues at jboss.org
Wed Jun 24 04:45:15 EDT 2020


Matteo Casalino created DROOLS-5449:
---------------------------------------

             Summary: ClassCastException upon unreferenced declare update
                 Key: DROOLS-5449
                 URL: https://issues.redhat.com/browse/DROOLS-5449
             Project: Drools
          Issue Type: Bug
          Components: core engine
    Affects Versions: 7.38.0.Final
            Reporter: Matteo Casalino
            Assignee: Mario Fusco
         Attachments: class-cast-exception-on-unreferenced-declare-update.zip

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:


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

is updated to:


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

the following exception it thrown by _fireAllRules()_:
 
{noformat}
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{noformat}



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list