Skip to content

Commit

Permalink
Fix flaky test GracefulExecutorServicesShutdownTest.shouldTerminateWh…
Browse files Browse the repository at this point in the history
…enFutureIsCancelled (apache#10592)

* fix flaky test GracefulExecutorServicesShutdownTest.shouldTerminateWhenFutureIsCancelled

* avoid import *
  • Loading branch information
linlinnn authored May 14, 2021
1 parent c4098d6 commit 55376af
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.testng.annotations.Test;
import org.awaitility.Awaitility;

public class GracefulExecutorServicesShutdownTest {

Expand Down Expand Up @@ -151,8 +152,8 @@ public void shouldTerminateWhenFutureIsCancelled() throws InterruptedException {
future.cancel(false);

// then
assertTrue(awaitTerminationInterrupted.get(),
"awaitTermination should have been interrupted");
Awaitility.await().untilAsserted(() -> assertTrue(awaitTerminationInterrupted.get(),
"awaitTermination should have been interrupted"));
verify(executorService, times(1)).awaitTermination(anyLong(), any());
verify(executorService, times(1)).shutdownNow();
}
Expand Down

0 comments on commit 55376af

Please sign in to comment.