|
35 | 35 | import ai.timefold.solver.core.config.solver.SolverConfig; |
36 | 36 | import ai.timefold.solver.core.config.solver.termination.DiminishedReturnsTerminationConfig; |
37 | 37 | import ai.timefold.solver.core.config.solver.termination.TerminationConfig; |
| 38 | +import ai.timefold.solver.core.enterprise.TimefoldSolverEnterpriseService; |
38 | 39 | import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor; |
39 | 40 | import ai.timefold.solver.core.impl.io.jaxb.SolverConfigIO; |
40 | 41 | import ai.timefold.solver.spring.boot.autoconfigure.config.DiminishedReturnsProperties; |
@@ -261,14 +262,33 @@ private void loadSolverConfig(IncludeAbstractClassesEntityScanner entityScanner, |
261 | 262 | private void applyScoreDirectorFactoryProperties(IncludeAbstractClassesEntityScanner entityScanner, |
262 | 263 | SolverConfig solverConfig, SolverProperties solverProperties) { |
263 | 264 | applyScoreDirectorFactoryProperties(entityScanner, solverConfig); |
264 | | - if (solverProperties.getConstraintStreamAutomaticNodeSharing() != null |
265 | | - && solverProperties.getConstraintStreamAutomaticNodeSharing()) { |
| 265 | + if (solverProperties.getConstraintStreamAutomaticNodeSharing() != null) { |
266 | 266 | if (NativeDetector.inNativeImage()) { |
267 | | - throw new UnsupportedOperationException( |
268 | | - "Constraint stream automatic node sharing is unsupported in a Spring native image."); |
| 267 | + if (solverProperties.getConstraintStreamAutomaticNodeSharing()) { |
| 268 | + // We are in enterprise, so log a note |
| 269 | + LOG.debug(""" |
| 270 | + Constraint stream automatic node sharing was disabled because it \ |
| 271 | + is unsupported in a Spring native image."""); |
| 272 | + } |
| 273 | + Objects.requireNonNull(solverConfig.getScoreDirectorFactoryConfig()) |
| 274 | + .setConstraintStreamAutomaticNodeSharing(false); |
| 275 | + } else { |
| 276 | + Objects.requireNonNull(solverConfig.getScoreDirectorFactoryConfig()) |
| 277 | + .setConstraintStreamAutomaticNodeSharing(solverProperties.getConstraintStreamAutomaticNodeSharing()); |
| 278 | + } |
| 279 | + } else if (NativeDetector.inNativeImage()) { |
| 280 | + // Explicitly set it to disabled in a native image if unspecified so |
| 281 | + // the solver does not try to node share when enterprise is used. |
| 282 | + if (TimefoldSolverEnterpriseService.loadOrDefault( |
| 283 | + ignored -> true, |
| 284 | + () -> false)) { |
| 285 | + // We are in enterprise, so log a note |
| 286 | + LOG.debug(""" |
| 287 | + Constraint stream automatic node sharing was disabled because it \ |
| 288 | + is unsupported in a Spring native image."""); |
269 | 289 | } |
270 | 290 | Objects.requireNonNull(solverConfig.getScoreDirectorFactoryConfig()) |
271 | | - .setConstraintStreamAutomaticNodeSharing(true); |
| 291 | + .setConstraintStreamAutomaticNodeSharing(false); |
272 | 292 | } |
273 | 293 | if (solverProperties.getConstraintStreamProfilingEnabled() != null) { |
274 | 294 | Objects.requireNonNull(solverConfig.getScoreDirectorFactoryConfig()) |
|
0 commit comments