# HG changeset patch # User dfuchs # Date 1512392405 0 # Node ID cfa4f84b7fcc1ab611d01a815de9bef9678673e2 # Parent 94fd10959e8bc39f2e80b8c321ee3085cafdf245 http-client-branch: 8192962: issue with BUFFER_UNDERFLOW diff -r 94fd10959e8b -r cfa4f84b7fcc src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java Sun Dec 03 20:56:29 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java Mon Dec 04 13:00:05 2017 +0000 @@ -363,7 +363,7 @@ // check for 101 switching protocols // 101 responses are not supposed to contain a body. // => should we fail if there is one? - debug.log(Level.DEBUG, "Upgrading async %s" + e.connection()); + debug.log(Level.DEBUG, "Upgrading async %s", e.connection()); return e.readBodyAsync(this::ignoreBody, false, parentExecutor) .thenCompose((T v) -> {// v is null debug.log(Level.DEBUG, "Ignored body"); @@ -408,7 +408,7 @@ s.cancelImpl(t); return MinimalFuture.failedFuture(t); } - debug.log(Level.DEBUG, "Getting response async %s" + s); + debug.log(Level.DEBUG, "Getting response async %s", s); return s.getResponseAsync(null); });} ); diff -r 94fd10959e8b -r cfa4f84b7fcc src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/SSLFlowDelegate.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/SSLFlowDelegate.java Sun Dec 03 20:56:29 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/SSLFlowDelegate.java Mon Dec 04 13:00:05 2017 +0000 @@ -318,6 +318,7 @@ if (result.status() == Status.BUFFER_UNDERFLOW) { debugr.log(Level.DEBUG, "BUFFER_UNDERFLOW"); // not enough data in the read buffer... + requestMore(); synchronized (readBufferLock) { // check if we have received some data if (readBuf.remaining() > len) continue; diff -r 94fd10959e8b -r cfa4f84b7fcc src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/SubscriberWrapper.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/SubscriberWrapper.java Sun Dec 03 20:56:29 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/SubscriberWrapper.java Mon Dec 04 13:00:05 2017 +0000 @@ -76,6 +76,7 @@ private final CompletableFuture cf; private final SequentialScheduler pushScheduler; private final AtomicReference errorRef = new AtomicReference<>(); + final AtomicLong upstreamWindow = new AtomicLong(0); /** * Wraps the given downstream subscriber. For each call to {@link @@ -309,8 +310,6 @@ } } - AtomicLong upstreamWindow = new AtomicLong(0); - void upstreamWindowUpdate() { long downstreamQueueSize = outputQ.size(); long n = upstreamWindowUpdate(upstreamWindow.get(), downstreamQueueSize); @@ -348,6 +347,12 @@ upstreamSubscription.request(n); } + protected void requestMore() { + if (upstreamWindow.get() == 0) { + upstreamRequest(1); + } + } + public long upstreamWindow() { return upstreamWindow.get(); }