Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions test/jdk/java/net/httpclient/CancelRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpsConfigurator;
import com.sun.net.httpserver.HttpsServer;
import jdk.internal.net.http.common.OperationTrackers.Tracker;
import jdk.test.lib.RandomFactory;
import jdk.test.lib.net.SimpleSSLContext;
import org.testng.ITestContext;
Expand Down Expand Up @@ -305,6 +306,7 @@ public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterrup
for (int i=0; i< ITERATION_COUNT; i++) {
if (!sameClient || client == null)
client = newHttpClient(sameClient);
Tracker tracker = TRACKER.getTracker(client);

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

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

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

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

var error = TRACKER.check(1,
var error = TRACKER.check(tracker, 200,
(t) -> t.getOutstandingOperations() > 0 || t.getOutstandingSubscribers() > 0,
"subscribers for testPostSendAsync(%s)\n\t step [%s]".formatted(req.uri(), i),
false);
Expand All @@ -508,6 +511,8 @@ public void testPostInterrupt(String uri, boolean sameClient)
for (int i=0; i< ITERATION_COUNT; i++) {
if (!sameClient || client == null)
client = newHttpClient(sameClient);
Tracker tracker = TRACKER.getTracker(client);

Thread main = Thread.currentThread();
CompletableFuture<Thread> interruptingThread = new CompletableFuture<>();
Runnable interrupt = () -> {
Expand Down Expand Up @@ -552,7 +557,7 @@ public void testPostInterrupt(String uri, boolean sameClient)
throw failed;
}

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