-
Enhancement
-
Resolution: Done
-
Minor
-
None
-
None
-
2020 Week 43-45 (from Okt 19)
-
2
-
Undefined
-
NEW
-
NEW
DroolsConstraintSession has
@Override public void update(Object fact) { FactHandle factHandle = kieSession.getFactHandle(fact); kieSession.update(factHandle, fact); }
but DroolsScoreDirector has:
private void update(Object entity, String variableName) { FactHandle factHandle = kieSession.getFactHandle(entity); if (factHandle == null) { throw new IllegalArgumentException("The entity (" + entity + ") was never added to this ScoreDirector.\n" + "Maybe that specific instance is not in the return values of the " + PlanningSolution.class.getSimpleName() + "'s entity members (" + getSolutionDescriptor().getEntityMemberAndEntityCollectionMemberNames() + ")."); } kieSession.update(factHandle, entity, variableName); }
The former gives the follow error message which is not helpful. The former should have the if factHandle== null fail fast check too.
Caused by: java.lang.NullPointerException
at org.drools.core.common.NamedEntryPoint.update(NamedEntryPoint.java:353)
at org.drools.core.common.NamedEntryPoint.update(NamedEntryPoint.java:338)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.update(StatefulKnowledgeSessionImpl.java:1587)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.update(StatefulKnowledgeSessionImpl.java:1559)
at org.optaplanner.core.impl.score.stream.drools.DroolsConstraintSession.update(DroolsConstraintSession.java:47)
at org.optaplanner.core.impl.score.director.stream.ConstraintStreamScoreDirector.afterVariableChanged(ConstraintStreamScoreDirector.java:141)
at org.optaplanner.core.impl.domain.variable.inverserelation.SingletonInverseVariableListener.retract(SingletonInverseVariableListener.java:96)
at org.optaplanner.core.impl.domain.variable.inverserelation.SingletonInverseVariableListener.beforeVariableChanged(SingletonInverseVariableListener.java:46)
at org.optaplanner.core.impl.domain.variable.listener.support.VariableListenerSupport.beforeVariableChanged(VariableListenerSupport.java:174)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.beforeVariableChanged(AbstractScoreDirector.java:433)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.changeVariableFacade(AbstractScoreDirector.java:446)
at org.optaplanner.core.impl.heuristic.selector.move.generic.chained.ChainedChangeMove.doMoveOnGenuineVariables(ChainedChangeMove.java:74)
at org.optaplanner.core.impl.heuristic.move.AbstractMove.doMove(AbstractMove.java:36)
at org.optaplanner.core.impl.heuristic.move.AbstractMove.doMove(AbstractMove.java:31)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.doAndProcessMove(AbstractScoreDirector.java:178)
at org.optaplanner.core.impl.heuristic.thread.MoveThreadRunner.run(MoveThreadRunner.java:146)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
Same logic for added/delete etc.