Skip to content

Commit

Permalink
Better exception message for ShutdownNow
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuch committed Aug 22, 2024
1 parent 0436091 commit da64bb8
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions test/jdk/java/net/httpclient/ShutdownNow.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,16 @@ void testConcurrent(String uriString) throws Exception {
}
CompletableFuture.allOf(responses.toArray(new CompletableFuture<?>[0])).get();
} finally {
if (client.awaitTermination(Duration.ofMillis(2000))) {
if (client.awaitTermination(Duration.ofMillis(2500))) {
out.println("Client terminated within expected delay");
assertTrue(client.isTerminated());
} else {
System.out.println(TRACKER.diagnose(client));
if (client.awaitTermination(Duration.ofMillis(500))) {
throw new AssertionError("client still running: " + TRACKER.diagnose(client));
}
client = null;
var error = TRACKER.check(500);
if (error != null) throw error;
throw new AssertionError("client was still running, but exited after further delay: "
+ "timeout should be adjusted");
}
assertTrue(client.isTerminated());
}
}

Expand Down Expand Up @@ -275,15 +276,16 @@ void testSequential(String uriString) throws Exception {
}).thenCompose((c) -> c).get();
}
} finally {
if (client.awaitTermination(Duration.ofMillis(2000))) {
if (client.awaitTermination(Duration.ofMillis(2500))) {
out.println("Client terminated within expected delay");
assertTrue(client.isTerminated());
} else {
System.out.println(TRACKER.diagnose(client));
if (client.awaitTermination(Duration.ofMillis(500))) {
throw new AssertionError("client still running: " + TRACKER.diagnose(client));
}
client = null;
var error = TRACKER.check(500);
if (error != null) throw error;
throw new AssertionError("client was still running, but exited after further delay: "
+ "timeout should be adjusted");
}
assertTrue(client.isTerminated());
}
}

Expand Down

0 comments on commit da64bb8

Please sign in to comment.