[
https://issues.redhat.com/browse/DROOLS-5449?page=com.atlassian.jira.plug...
]
Mario Fusco commented on DROOLS-5449:
-------------------------------------
[~mcasalino] I understand that this behavior is misleading. It is caused by the fact that
the problem gets triggered only after the engine have attempted to transform the mvel
interpreted constraint into a java class for faster evaluation. I could maybe prevent this
problem by checking if you're using the "right" FactType and throw an early
error (or warning) in case you are not. However this additional check would be a useless
waste of time in 99.9...% of cases and for this reason I'd prefer to avoid it. I hope
you agree. Also consider that using the executable model you shouldn't have this
issue.
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
Priority: Major
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)