-
Enhancement
-
Resolution: Unresolved
-
Major
-
None
-
7.6.0.Final
-
None
-
NEW
-
NEW
This is needed to avoid try-catching kieSession.setGlobal(...) in for example optaplanner.
This code
kieSession.setGlobal("scoreHolder", workingScoreHolder);
throws
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Illegal class for global. Expected [org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScoreHolder], found [org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScoreHolder]. at org.drools.core.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessionImpl.java:1189) at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.resetKieSession(DroolsScoreDirector.java:79) at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.setWorkingSolution(DroolsScoreDirector.java:69)
because the user didn't align his global field ScoreHolder type with his domain classes score type.
Instead they should get
IllegalStateException: your global field ScoreHolder type (...) does not align with your domain classes score type (...).
To do this, we need to have KieBase.getGlobalType("scoreHolder") return HardSoftScoreHolder.class, so I can check it's not equal HardSoftLongScoreHolder.class, during bootstrap, instead of try-catching every setGlobal() call.
Furthermore, I believe this should be added in the public api - it is clearly an api gap. But I can work with adding this in the internal api too.