Skip to content

Commit 417761d

Browse files
committed
8295991: java/net/httpclient/CancelRequestTest.java fails intermittently
Backport-of: e15d2419ab9c812a3dc18812406f7b59976d2143
1 parent 105c486 commit 417761d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.sun.net.httpserver.HttpServer;
3939
import com.sun.net.httpserver.HttpsConfigurator;
4040
import com.sun.net.httpserver.HttpsServer;
41+
import jdk.internal.net.http.common.OperationTrackers.Tracker;
4142
import jdk.test.lib.RandomFactory;
4243
import jdk.test.lib.net.SimpleSSLContext;
4344
import org.testng.ITestContext;
@@ -305,6 +306,7 @@ public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterrup
305306
for (int i=0; i< ITERATION_COUNT; i++) {
306307
if (!sameClient || client == null)
307308
client = newHttpClient(sameClient);
309+
Tracker tracker = TRACKER.getTracker(client);
308310

309311
HttpRequest req = HttpRequest.newBuilder(URI.create(uri))
310312
.GET()
@@ -379,7 +381,7 @@ public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterrup
379381
assertEquals(cf2.isCancelled(), false);
380382
assertEquals(latch.getCount(), 0);
381383

382-
var error = TRACKER.check(1,
384+
var error = TRACKER.check(tracker, 200,
383385
(t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0,
384386
"subscribers for testGetSendAsync(%s)\n\t step [%s]".formatted(req.uri(), i),
385387
false);
@@ -398,6 +400,7 @@ public void testPostSendAsync(String uri, boolean sameClient, boolean mayInterru
398400
for (int i=0; i< ITERATION_COUNT; i++) {
399401
if (!sameClient || client == null)
400402
client = newHttpClient(sameClient);
403+
Tracker tracker = TRACKER.getTracker(client);
401404

402405
CompletableFuture<CompletableFuture<?>> cancelFuture = new CompletableFuture<>();
403406

@@ -490,7 +493,7 @@ public Iterator<byte[]> iterator() {
490493
assertEquals(cf2.isCancelled(), false);
491494
assertEquals(latch.getCount(), 0);
492495

493-
var error = TRACKER.check(1,
496+
var error = TRACKER.check(tracker, 200,
494497
(t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0,
495498
"subscribers for testPostSendAsync(%s)\n\t step [%s]".formatted(req.uri(), i),
496499
false);
@@ -508,6 +511,8 @@ public void testPostInterrupt(String uri, boolean sameClient)
508511
for (int i=0; i< ITERATION_COUNT; i++) {
509512
if (!sameClient || client == null)
510513
client = newHttpClient(sameClient);
514+
Tracker tracker = TRACKER.getTracker(client);
515+
511516
Thread main = Thread.currentThread();
512517
CompletableFuture<Thread> interruptingThread = new CompletableFuture<>();
513518
Runnable interrupt = () -> {
@@ -552,7 +557,7 @@ public void testPostInterrupt(String uri, boolean sameClient)
552557
throw failed;
553558
}
554559

555-
var error = TRACKER.check(1,
560+
var error = TRACKER.check(tracker, 200,
556561
(t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0,
557562
"subscribers for testPostInterrupt(%s)\n\t step [%s]".formatted(req.uri(), i),
558563
false);

0 commit comments

Comments
 (0)