Skip to content

Commit

Permalink
test: common: Attempt to fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlschuetter committed Jun 30, 2024
1 parent 6748b1a commit 7025a04
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void testUnblockAcceptsWithoutSoTimeout() throws Exception {
testUnblockAccepts(0);
}

@SuppressWarnings("PMD.CognitiveComplexity")
private void testUnblockAccepts(int timeout) throws Exception {
assertTimeoutPreemptively(Duration.ofSeconds(30), () -> {
try (ServerSocket serverSocket = newServerSocketBindOn(getServerBindAddress())) {
Expand Down Expand Up @@ -110,6 +111,13 @@ public void run() {
if (active == numThreads) {
checkFailedTestActuallySupported();
}

int attemptsLeft = 50;
while (active > 0 && attemptsLeft-- > 0) {
Thread.sleep(100);
active = threadPool.getActiveCount();
}

assertEquals(0, active, "There should be no pending accepts");
}
});
Expand Down

0 comments on commit 7025a04

Please sign in to comment.