File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
src/test/java/dev/failsafe Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ public void testFallbackTimeoutWithBlockedSupplier() {
206206 fbStats .reset ();
207207 }, Failsafe .with (fallback ).compose (timeout ), ctx -> {
208208 System .out .println ("Executing" );
209- Thread .sleep (100 );
209+ Thread .sleep (200 );
210210 throw new Exception ();
211211 }, (f , e ) -> {
212212 assertEquals (e .getAttemptCount (), 1 );
@@ -216,11 +216,11 @@ public void testFallbackTimeoutWithBlockedSupplier() {
216216 }, IllegalStateException .class );
217217
218218 // Test without interrupt
219- Timeout <Object > timeout = withStatsAndLogs (Timeout .builder (Duration .ofMillis (1 )), timeoutStats ).build ();
219+ Timeout <Object > timeout = withStatsAndLogs (Timeout .builder (Duration .ofMillis (100 )), timeoutStats ).build ();
220220 test .accept (timeout );
221221
222222 // Test with interrupt
223- timeout = withStatsAndLogs (Timeout .builder (Duration .ofMillis (1 )).withInterrupt (), timeoutStats ).build ();
223+ timeout = withStatsAndLogs (Timeout .builder (Duration .ofMillis (100 )).withInterrupt (), timeoutStats ).build ();
224224 test .accept (timeout );
225225 }
226226
Original file line number Diff line number Diff line change 88
99import java .time .Duration ;
1010import java .util .concurrent .ExecutionException ;
11+ import java .util .concurrent .ExecutorService ;
12+ import java .util .concurrent .Executors ;
1113import java .util .concurrent .atomic .AtomicBoolean ;
1214
1315import static org .testng .Assert .assertTrue ;
1416
1517@ Test
1618public class Issue231Test {
1719 /**
18- * Timeout, even with interruption, should wait for the execution to complete.
20+ * Timeout, even with interruption, should wait for the execution to complete before completing the future .
1921 */
2022 public void shouldWaitForExecutionCompletion () {
23+ // Use a separate executorService for this test in case the common pool is full
24+ ExecutorService executorService = Executors .newFixedThreadPool (2 );
2125 Timeout <Object > timeout = Timeout .builder (Duration .ofMillis (100 )).withInterrupt ().build ();
2226 AtomicBoolean executionCompleted = new AtomicBoolean ();
23- Asserts .assertThrows (() -> Failsafe .with (timeout ).runAsync (() -> {
27+ Asserts .assertThrows (() -> Failsafe .with (timeout ).with ( executorService ). runAsync (() -> {
2428 try {
2529 Thread .sleep (1000 );
2630 } catch (InterruptedException ignore ) {
You can’t perform that action at this time.
0 commit comments