Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-484

Fail fast if value range provider value type doesn't match the planning variable's value type

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 6.4.0.Beta1
    • 6.3.0.Final
    • optaplanner-core
    • None
    • NEW
    • NEW

      see http://stackoverflow.com/questions/34029457/optaplanner-classcastexception-at-comparatorselectionsorter

      better than getting this unhelpful exception:

      Exception in thread "main" java.lang.ClassCastException: org.demo.DemoApp.domain.JobAssignment cannot be cast to org.demo.DemoApp.domain.Employee
      at org.demo.DemoApp.domain.solver.EmployeeStrengthComparator.compare(EmployeeStrengthComparator.java:12)
      at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
      at java.util.TimSort.sort(TimSort.java:220)
      at java.util.Arrays.sort(Arrays.java:1512)
      at java.util.ArrayList.sort(ArrayList.java:1454)
      at java.util.Collections.sort(Collections.java:175)
      at org.optaplanner.core.impl.heuristic.selector.common.decorator.ComparatorSelectionSorter.sort(ComparatorSelectionSorter.java:45)
      at org.optaplanner.core.impl.heuristic.selector.value.decorator.SortingValueSelector.constructCache(SortingValueSelector.java:43)
      at org.optaplanner.core.impl.heuristic.selector.common.SelectionCacheLifecycleBridge.phaseStarted(SelectionCacheLifecycleBridge.java:49)
      at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:39)
      

      or this one

      java.lang.IllegalArgumentException: argument type mismatch
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.optaplanner.core.impl.domain.common.accessor.BeanPropertyMemberAccessor.executeSetter(BeanPropertyMemberAccessor.java:86)
      

              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: