8157045: NPE during websocket communication with wss
authorchegar
Wed, 15 Jun 2016 19:18:19 +0100
changeset 38967 0967b6d49eef
parent 38966 308f5cc7d5f6
child 38968 fdefde511416
8157045: NPE during websocket communication with wss Reviewed-by: michaelm, prappo
jdk/src/java.httpclient/share/classes/java/net/http/SSLConnection.java
jdk/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java
jdk/src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java
--- a/jdk/src/java.httpclient/share/classes/java/net/http/SSLConnection.java	Wed Jun 15 10:25:25 2016 -0700
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/SSLConnection.java	Wed Jun 15 19:18:19 2016 +0100
@@ -142,6 +142,9 @@
         // TODO: check for closure
         String s = "Receive) ";
         //debugPrint(s, r.buf);
+        if (r.result.bytesProduced() > 0) {
+            assert buf == r.buf;
+        }
         return r.result.bytesProduced();
     }
 
--- a/jdk/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java	Wed Jun 15 10:25:25 2016 -0700
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java	Wed Jun 15 19:18:19 2016 +0100
@@ -344,8 +344,8 @@
         /* we wait until some user data arrives */
         int mark = dst.position();
         WrapperResult r = null;
-        assert dst.position() == 0;
-        while (dst.position() == 0) {
+        int pos = dst.position();
+        while (dst.position() == pos) {
             r = wrapper.recvAndUnwrap (dst);
             dst = (r.buf != dst) ? r.buf: dst;
             Status status = r.result.getStatus();
--- a/jdk/src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java	Wed Jun 15 10:25:25 2016 -0700
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java	Wed Jun 15 19:18:19 2016 +0100
@@ -150,6 +150,10 @@
         // TODO: check for closure
         String s = "Receive) ";
         //debugPrint(s, r.buf);
+        if (r.result.bytesProduced() > 0) {
+            assert buf == r.buf;
+        }
+
         return r.result.bytesProduced();
     }