From b48a0e79c4166cec0697ce4b30660601146dd936 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 15 Jun 2016 19:18:19 +0100 Subject: [PATCH] 8157045: NPE during websocket communication with wss Reviewed-by: michaelm, prappo --- .../share/classes/java/net/http/SSLConnection.java | 3 +++ .../share/classes/java/net/http/SSLDelegate.java | 4 ++-- .../share/classes/java/net/http/SSLTunnelConnection.java | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/SSLConnection.java b/jdk/src/java.httpclient/share/classes/java/net/http/SSLConnection.java index 932c5b1c0f5..926afd2258b 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/SSLConnection.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/SSLConnection.java @@ -142,6 +142,9 @@ class SSLConnection extends HttpConnection { // TODO: check for closure String s = "Receive) "; //debugPrint(s, r.buf); + if (r.result.bytesProduced() > 0) { + assert buf == r.buf; + } return r.result.bytesProduced(); } diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java b/jdk/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java index cf4203bf76d..80c378e39cf 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java @@ -344,8 +344,8 @@ class SSLDelegate { /* 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(); diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java b/jdk/src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java index fe8e766af77..3b33d468185 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java @@ -150,6 +150,10 @@ class SSLTunnelConnection extends HttpConnection { // TODO: check for closure String s = "Receive) "; //debugPrint(s, r.buf); + if (r.result.bytesProduced() > 0) { + assert buf == r.buf; + } + return r.result.bytesProduced(); }