Merge branch '7.0.x'

This commit is contained in:
Brian Clozel
2026-07-12 11:55:38 +02:00
@@ -21,6 +21,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.jupiter.api.Test;
@@ -153,17 +154,18 @@ class SimpleAsyncTaskExecutorTests {
@Test
void taskTerminationTimeoutWithImmediateCancel() {
AtomicBoolean finished = new AtomicBoolean();
AtomicReference<Runnable> captured = new AtomicReference<>();
Future<?> future;
try (SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor()) {
try (SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor() {
@Override
protected void doExecute(Runnable task) {
captured.set(task);
}
}) {
executor.setTaskTerminationTimeout(100);
future = executor.submit(() -> {
if (finished.get()) {
throw new IllegalStateException();
}
});
future = executor.submit(() -> {});
}
finished.set(true);
assertThatExceptionOfType(CancellationException.class).isThrownBy(captured.get()::run);
assertThatExceptionOfType(CancellationException.class).isThrownBy(future::get);
}