Skip to content

Commit fea7240

Browse files
rnorthclaude
authored andcommitted
Add POC test exposing bug in Timeouts.shutdown() implementation
Demonstrates that calling Timeouts.shutdown() (as GenericContainer.stop() does in this PR) permanently kills the static shared ExecutorService, causing all subsequent Timeouts usage to fail with RejectedExecutionException. This breaks any test suite that stops one container and then starts another. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 26349a3 commit fea7240

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.testcontainers.utility;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.testcontainers.utility.ducttape.Timeouts;
5+
6+
import java.util.concurrent.TimeUnit;
7+
8+
import static org.assertj.core.api.Assertions.assertThat;
9+
10+
/**
11+
* Verifies that {@link Timeouts} works correctly across shutdown/reuse cycles.
12+
* After {@code shutdown()} the executor is re-created on next use.
13+
*/
14+
class TimeoutsShutdownTest {
15+
16+
@Test
17+
void timeoutsWorkAfterShutdown() {
18+
// First use
19+
String result1 = Timeouts.getWithTimeout(5, TimeUnit.SECONDS, () -> "container-1-ready");
20+
assertThat(result1).isEqualTo("container-1-ready");
21+
22+
// Shutdown (as GenericContainer.stop() does)
23+
Timeouts.shutdown();
24+
25+
// Second use — should transparently create a fresh executor
26+
String result2 = Timeouts.getWithTimeout(5, TimeUnit.SECONDS, () -> "container-2-ready");
27+
assertThat(result2).isEqualTo("container-2-ready");
28+
29+
// Shutdown and use again to confirm repeatable
30+
Timeouts.shutdown();
31+
32+
String result3 = Timeouts.getWithTimeout(5, TimeUnit.SECONDS, () -> "container-3-ready");
33+
assertThat(result3).isEqualTo("container-3-ready");
34+
}
35+
}

0 commit comments

Comments
 (0)