http-client-branch: 8196848: SplitResponseSSL test failing intermitently (but rarely) with HttpClientImpl shutting down. http-client-branch
authordfuchs
Tue, 06 Feb 2018 15:34:08 +0000
branchhttp-client-branch
changeset 56081 20c6742e5545
parent 56080 64846522c0d5
child 56082 1da51fab3032
http-client-branch: 8196848: SplitResponseSSL test failing intermitently (but rarely) with HttpClientImpl shutting down.
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/HttpClientImpl.java
test/jdk/ProblemList.txt
test/jdk/java/net/httpclient/DigestEchoClient.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/HttpClientImpl.java	Tue Feb 06 15:20:30 2018 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/HttpClientImpl.java	Tue Feb 06 15:34:08 2018 +0000
@@ -520,8 +520,10 @@
         void eventUpdated(AsyncEvent e) throws ClosedChannelException {
             if (Thread.currentThread() == this) {
                 SelectionKey key = e.channel().keyFor(selector);
-                SelectorAttachment sa = (SelectorAttachment) key.attachment();
-                if (sa != null) sa.register(e);
+                if (key != null) {
+                    SelectorAttachment sa = (SelectorAttachment) key.attachment();
+                    if (sa != null) sa.register(e);
+                }
             } else {
                 register(e);
             }
@@ -775,7 +777,11 @@
             pending.add(e);
             if (reRegister) {
                 // first time registration happens here also
-                chan.register(selector, interestOps, this);
+                try {
+                    chan.register(selector, interestOps, this);
+                } catch (CancelledKeyException x) {
+                    abortPending(x);
+                }
             }
         }
 
--- a/test/jdk/ProblemList.txt	Tue Feb 06 15:20:30 2018 +0000
+++ b/test/jdk/ProblemList.txt	Tue Feb 06 15:34:08 2018 +0000
@@ -217,7 +217,6 @@
 
 java/net/DatagramSocket/SendDatagramToBadAddress.java           7143960 macosx-all
 
-java/net/httpclient/SplitResponseSSL.java                       8194151 windows-all
 
 ############################################################################
 
--- a/test/jdk/java/net/httpclient/DigestEchoClient.java	Tue Feb 06 15:20:30 2018 +0000
+++ b/test/jdk/java/net/httpclient/DigestEchoClient.java	Tue Feb 06 15:34:08 2018 +0000
@@ -440,6 +440,11 @@
 
                 if (addHeaders && !preemptive && (i==0 || isSchemeDisabled())) {
                     assert resp.statusCode() == 401 || resp.statusCode() == 407;
+                    Stream<String> respBody = resp.body();
+                    if (respBody != null) {
+                        System.out.printf("Response body (%s):\n", resp.statusCode());
+                        respBody.forEach(System.out::println);
+                    }
                     System.out.println(String.format("%s received: adding header %s: %s",
                             resp.statusCode(), authorizationKey(authType), auth));
                     request = HttpRequest.newBuilder(uri).version(clientVersion)