http-client-branch: review comment - add more coverage for HttpClientImpl operations ref count
--- a/test/jdk/java/net/httpclient/CancelledResponse.java Mon Apr 16 10:27:52 2018 +0100
+++ b/test/jdk/java/net/httpclient/CancelledResponse.java Mon Apr 16 13:57:06 2018 +0100
@@ -56,8 +56,9 @@
* @test
* @bug 8087112
* @library /lib/testlibrary
+ * @modules java.net.http/jdk.internal.net.http.common
* @build jdk.testlibrary.SimpleSSLContext
- * @build MockServer
+ * @build MockServer ReferenceTracker
* @run main/othervm CancelledResponse
* @run main/othervm CancelledResponse SSL
*/
@@ -88,6 +89,7 @@
"aliquip ex ea commodo consequat."
};
+ static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE;
final ServerSocketFactory factory;
final SSLContext context;
final boolean useSSL;
@@ -108,7 +110,7 @@
} else {
client = HttpClient.newHttpClient();
}
- return client;
+ return TRACKER.track(client);
}
public static void main(String[] args) throws Exception {
@@ -118,15 +120,32 @@
}
CancelledResponse sp = new CancelledResponse(useSSL);
- for (Version version : Version.values()) {
- for (boolean serverKeepalive : new boolean[]{ true, false }) {
- // Note: the mock server doesn't support Keep-Alive, but
- // pretending that it might exercises code paths in and out of
- // the connection pool, and retry logic
- for (boolean async : new boolean[]{ true, false }) {
- sp.test(version, serverKeepalive, async);
+ Throwable failed = null;
+ try {
+ for (Version version : Version.values()) {
+ for (boolean serverKeepalive : new boolean[]{true, false}) {
+ // Note: the mock server doesn't support Keep-Alive, but
+ // pretending that it might exercises code paths in and out of
+ // the connection pool, and retry logic
+ for (boolean async : new boolean[]{true, false}) {
+ sp.test(version, serverKeepalive, async);
+ }
}
}
+ } catch (Exception | Error t) {
+ failed = t;
+ throw t;
+ } finally {
+ Thread.sleep(100);
+ AssertionError trackFailed = TRACKER.check(500);
+ if (trackFailed != null) {
+ if (failed != null) {
+ failed.addSuppressed(trackFailed);
+ if (failed instanceof Error) throw (Error) failed;
+ if (failed instanceof Exception) throw (Exception) failed;
+ }
+ throw trackFailed;
+ }
}
}
--- a/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java Mon Apr 16 10:27:52 2018 +0100
+++ b/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java Mon Apr 16 13:57:06 2018 +0100
@@ -27,7 +27,7 @@
* immediately with an InputStream which issues bad
* requests
* @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.testlibrary.SimpleSSLContext ReferenceTracker
* @modules java.base/sun.net.www.http
* java.net.http/jdk.internal.net.http.common
* java.net.http/jdk.internal.net.http.frame
@@ -200,12 +200,13 @@
};
}
+ final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE;
HttpClient newHttpClient() {
- return HttpClient.newBuilder()
- .proxy(HttpClient.Builder.NO_PROXY)
- .executor(executor)
- .sslContext(sslContext)
- .build();
+ return TRACKER.track(HttpClient.newBuilder()
+ .proxy(HttpClient.Builder.NO_PROXY)
+ .executor(executor)
+ .sslContext(sslContext)
+ .build());
}
@Test(dataProvider = "variants")
@@ -485,10 +486,17 @@
@AfterTest
public void teardown() throws Exception {
- httpTestServer.stop();
- httpsTestServer.stop();
- http2TestServer.stop();
- https2TestServer.stop();
+ AssertionError fail = TRACKER.check(500);
+ try {
+ httpTestServer.stop();
+ httpsTestServer.stop();
+ http2TestServer.stop();
+ https2TestServer.stop();
+ } finally {
+ if (fail != null) {
+ throw fail;
+ }
+ }
}
static final String WITH_BODY = "Lorem ipsum dolor sit amet, consectetur" +
--- a/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java Mon Apr 16 10:27:52 2018 +0100
+++ b/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java Mon Apr 16 13:57:06 2018 +0100
@@ -28,7 +28,7 @@
* immediately with a Publisher<List<ByteBuffer>> whose
* subscriber issues bad requests
* @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.testlibrary.SimpleSSLContext ReferenceTracker
* @modules java.base/sun.net.www.http
* java.net.http/jdk.internal.net.http.common
* java.net.http/jdk.internal.net.http.frame
@@ -145,12 +145,13 @@
};
}
+ final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE;
HttpClient newHttpClient() {
- return HttpClient.newBuilder()
+ return TRACKER.track(HttpClient.newBuilder()
.proxy(HttpClient.Builder.NO_PROXY)
.executor(executor)
.sslContext(sslContext)
- .build();
+ .build());
}
@Test(dataProvider = "variants")
@@ -417,10 +418,17 @@
@AfterTest
public void teardown() throws Exception {
- httpTestServer.stop();
- httpsTestServer.stop();
- http2TestServer.stop();
- https2TestServer.stop();
+ AssertionError fail = TRACKER.check(500);
+ try {
+ httpTestServer.stop();
+ httpsTestServer.stop();
+ http2TestServer.stop();
+ https2TestServer.stop();
+ } finally {
+ if (fail != null) {
+ throw fail;
+ }
+ }
}
static final String WITH_BODY = "Lorem ipsum dolor sit amet, consectetur" +