8301169: java/net/httpclient/ThrowingSubscribersAsInputStream.java,ThrowingSubscribersAsInputStreamAsync.java, and other httpclient tests failing on windows: Unable to establish loopback connection

Reviewed-by: aefimov, djelinski
This commit is contained in:
Daniel Fuchs 2023-04-25 15:48:12 +00:00
parent 07ea445b43
commit 98e8616a0c
3 changed files with 108 additions and 0 deletions

@ -388,6 +388,24 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters {
String body = response.join().body();
assertEquals(body, Stream.of(BODY.split("\\|")).collect(Collectors.joining()));
if (!sameClient) {
// Wait for the client to be garbage collected.
// we use the ReferenceTracker API rather than HttpClient::close here,
// because these tests inject faults by throwing inside callbacks, which
// is more likely to get HttpClient::close wedged until jtreg times out.
// By using the ReferenceTracker, we will get some diagnosis about what
// is keeping the client alive if it doesn't get GC'ed within the
// expected time frame.
var tracker = TRACKER.getTracker(client);
client = null;
System.gc();
System.out.println(now() + "waiting for client to shutdown: " + tracker.getName());
System.err.println(now() + "waiting for client to shutdown: " + tracker.getName());
var error = TRACKER.check(tracker, 10000);
if (error != null) throw error;
System.out.println(now() + "client shutdown normally: " + tracker.getName());
System.err.println(now() + "client shutdown normally: " + tracker.getName());
}
}
}
@ -470,6 +488,24 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters {
if (response != null) {
finisher.finish(where, response, thrower);
}
if (!sameClient) {
// Wait for the client to be garbage collected.
// we use the ReferenceTracker API rather than HttpClient::close here,
// because these tests inject faults by throwing inside callbacks, which
// is more likely to get HttpClient::close wedged until jtreg times out.
// By using the ReferenceTracker, we will get some diagnosis about what
// is keeping the client alive if it doesn't get GC'ed within the
// expected time frame.
var tracker = TRACKER.getTracker(client);
client = null;
System.gc();
System.out.println(now() + "waiting for client to shutdown: " + tracker.getName());
System.err.println(now() + "waiting for client to shutdown: " + tracker.getName());
var error = TRACKER.check(tracker, 10000);
if (error != null) throw error;
System.out.println(now() + "client shutdown normally: " + tracker.getName());
System.err.println(now() + "client shutdown normally: " + tracker.getName());
}
}
}

@ -340,6 +340,24 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters
assertEquals(promisedBody, promised.uri().toASCIIString());
}
assertEquals(3, pushPromises.size());
if (!sameClient) {
// Wait for the client to be garbage collected.
// we use the ReferenceTracker API rather than HttpClient::close here,
// because these tests inject faults by throwing inside callbacks, which
// is more likely to get HttpClient::close wedged until jtreg times out.
// By using the ReferenceTracker, we will get some diagnosis about what
// is keeping the client alive if it doesn't get GC'ed within the
// expected time frame.
var tracker = TRACKER.getTracker(client);
client = null;
System.gc();
System.out.println(now() + "waiting for client to shutdown: " + tracker.getName());
System.err.println(now() + "waiting for client to shutdown: " + tracker.getName());
var error = TRACKER.check(tracker, 10000);
if (error != null) throw error;
System.out.println(now() + "client shutdown normally: " + tracker.getName());
System.err.println(now() + "client shutdown normally: " + tracker.getName());
}
}
}
@ -425,6 +443,24 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters
if (response != null) {
finisher.finish(where, req.uri(), response, thrower, promiseMap);
}
if (!sameClient) {
// Wait for the client to be garbage collected.
// we use the ReferenceTracker API rather than HttpClient::close here,
// because these tests inject faults by throwing inside callbacks, which
// is more likely to get HttpClient::close wedged until jtreg times out.
// By using the ReferenceTracker, we will get some diagnosis about what
// is keeping the client alive if it doesn't get GC'ed within the
// expected time frame.
var tracker = TRACKER.getTracker(client);
client = null;
System.gc();
System.out.println(now() + "waiting for client to shutdown: " + tracker.getName());
System.err.println(now() + "waiting for client to shutdown: " + tracker.getName());
var error = TRACKER.check(tracker, 10000);
if (error != null) throw error;
System.out.println(now() + "client shutdown normally: " + tracker.getName());
System.err.println(now() + "client shutdown normally: " + tracker.getName());
}
}
}

@ -314,6 +314,24 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters
HttpResponse<String> response = client.send(req, handler);
String body = response.body();
assertEquals(URI.create(body).getPath(), URI.create(uri2).getPath());
if (!sameClient) {
// Wait for the client to be garbage collected.
// we use the ReferenceTracker API rather than HttpClient::close here,
// because these tests inject faults by throwing inside callbacks, which
// is more likely to get HttpClient::close wedged until jtreg times out.
// By using the ReferenceTracker, we will get some diagnosis about what
// is keeping the client alive if it doesn't get GC'ed within the
// expected time frame.
var tracker = TRACKER.getTracker(client);
client = null;
System.gc();
System.out.println(now() + "waiting for client to shutdown: " + tracker.getName());
System.err.println(now() + "waiting for client to shutdown: " + tracker.getName());
var error = TRACKER.check(tracker, 10000);
if (error != null) throw error;
System.out.println(now() + "client shutdown normally: " + tracker.getName());
System.err.println(now() + "client shutdown normally: " + tracker.getName());
}
}
}
@ -461,6 +479,24 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters
if (response != null) {
finisher.finish(where, response, thrower);
}
if (!sameClient) {
// Wait for the client to be garbage collected.
// we use the ReferenceTracker API rather than HttpClient::close here,
// because these tests inject faults by throwing inside callbacks, which
// is more likely to get HttpClient::close wedged until jtreg times out.
// By using the ReferenceTracker, we will get some diagnosis about what
// is keeping the client alive if it doesn't get GC'ed within the
// expected time frame.
var tracker = TRACKER.getTracker(client);
client = null;
System.gc();
System.out.println(now() + "waiting for client to shutdown: " + tracker.getName());
System.err.println(now() + "waiting for client to shutdown: " + tracker.getName());
var error = TRACKER.check(tracker, 10000);
if (error != null) throw error;
System.out.println(now() + "client shutdown normally: " + tracker.getName());
System.err.println(now() + "client shutdown normally: " + tracker.getName());
}
}
}