-
Bug
-
Resolution: Duplicate
-
Critical
-
None
-
None
-
None
-
Undefined
-
NEW
-
NEW
OptaPlanner requires an immutable class for a @PlanningId, such as Long, long, String or UUID. (It can't validate the immutability, but the javadocs says so).
As of 8.4.0, ConstraintVerifier throws an exception if it's not a Long:
java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Long (java.lang.String and java.lang.Long are in module java.base of loader 'bootstrap') at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.lambda$assertDistinctPlanningIds$2(DefaultSingleConstraintVerification.java:71) at java.base/java.util.stream.Collectors.lambda$groupingBy$53(Collectors.java:1127) at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.lambda$assertDistinctPlanningIds$6(DefaultSingleConstraintVerification.java:70) at java.base/java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1603) at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.assertDistinctPlanningIds(DefaultSingleConstraintVerification.java:62) at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.given(DefaultSingleConstraintVerification.java:95) at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.given(DefaultSingleConstraintVerification.java:39)
This needs test coverage (think TDD) and a fix. If the PAM 7.11 branch (8.6.x?) is already branched, the fix needs to be backported to that branch too.
- clones
-
PLANNER-2385 ConstraintVerifier must not presume the planningId is a Long (regression)
- Resolved