Skip to content

Commit c7f5aeb

Browse files
committed
Fix flaky test
1 parent 9318c4e commit c7f5aeb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

core/src/test/java/dev/failsafe/issues/Issue231Test.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88

99
import java.time.Duration;
1010
import java.util.concurrent.ExecutionException;
11+
import java.util.concurrent.ExecutorService;
12+
import java.util.concurrent.Executors;
1113
import java.util.concurrent.atomic.AtomicBoolean;
1214

1315
import static org.testng.Assert.assertTrue;
1416

15-
@Test(enabled = false)
17+
@Test
1618
public 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) {

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
<plugin>
169169
<groupId>org.jacoco</groupId>
170170
<artifactId>jacoco-maven-plugin</artifactId>
171-
<version>0.8.6</version>
171+
<version>0.8.7</version>
172172
<executions>
173173
<execution>
174174
<id>prepare-agent</id>

0 commit comments

Comments
 (0)