Skip to content

Commit 21e6391

Browse files
committed
8369319: java/net/httpclient/CancelRequestTest.java fails intermittently
Reviewed-by: dfuchs
1 parent 38fd794 commit 21e6391

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/jdk/java/net/httpclient/CancelRequestTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -273,8 +273,12 @@ HttpClient newHttpClient(boolean share) {
273273
// rewrap in "Request Cancelled" when the multi exchange was aborted...
274274
private static boolean isCancelled(Throwable t) {
275275
while (t instanceof ExecutionException) t = t.getCause();
276-
if (t instanceof CancellationException) return true;
277-
if (t instanceof IOException) return String.valueOf(t).contains("Request cancelled");
276+
Throwable cause = t;
277+
while (cause != null) {
278+
if (cause instanceof CancellationException) return true;
279+
if (cause instanceof IOException && String.valueOf(cause).contains("Request cancelled")) return true;
280+
cause = cause.getCause();
281+
}
278282
out.println("Not a cancellation exception: " + t);
279283
t.printStackTrace(out);
280284
return false;

0 commit comments

Comments
 (0)