Skip to content

Commit 2e9d73a

Browse files
authored
fix: semaphore release submitted to a dead executor (#2374)
1 parent a6bcbc8 commit 2e9d73a

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

core/src/main/java/ai/timefold/solver/core/impl/solver/ConsumerSupport.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ private void tryConsumeWaitingIntermediateBestSolution() {
8484
}
8585
if (activeConsumption.tryAcquire()) {
8686
scheduleIntermediateBestSolutionConsumption()
87-
.whenCompleteAsync((solution, throwable) -> {
87+
.whenComplete((unused, throwable) -> {
8888
activeConsumption.release();
8989
tryConsumeWaitingIntermediateBestSolution();
90-
}, consumerExecutor);
90+
});
9191
}
9292
}
9393

@@ -120,7 +120,7 @@ void consumeFirstInitializedSolution(Solution_ solution, EventProducerId produce
120120
this.firstInitializedSolution.getAndSet(solution); // Reachable more than once; problem change triggers restart.
121121
scheduleFirstInitializedSolutionConsumption(s -> firstInitializedSolutionConsumer
122122
.accept(new FirstInitializedSolutionEventImpl<>(s, producerId, isTerminatedEarly)))
123-
.whenCompleteAsync((unused, throwable) -> firstSolutionConsumption.release(), consumerExecutor);
123+
.whenComplete((unused, throwable) -> firstSolutionConsumption.release());
124124
}
125125

126126
private CompletableFuture<Void> scheduleFirstInitializedSolutionConsumption(Consumer<? super Solution_> solutionConsumer) {
@@ -153,8 +153,7 @@ void consumeStartSolverJob(Solution_ solution) {
153153
throw new IllegalStateException("Interrupted when waiting for the start solver job consumption.");
154154
}
155155
this.initialSolution.getAndSet(solution); // Reachable more than once; problem change triggers restart.
156-
scheduleStartJobConsumption().whenCompleteAsync((unused, throwable) -> startSolverJobConsumption.release(),
157-
consumerExecutor);
156+
scheduleStartJobConsumption().whenComplete((unused, throwable) -> startSolverJobConsumption.release());
158157
}
159158

160159
private CompletableFuture<Void> scheduleStartJobConsumption() {

0 commit comments

Comments
 (0)