# HG changeset patch # User dfuchs # Date 1510676932 0 # Node ID 4f699653026b4fa39cc4d452a0627c0af58ad354 # Parent cb1e2086ca36ab5798887c51c3b385316eba8c7e http-client-branch: Cleanup unneeded buffer instance variable from Http1Exchange diff -r cb1e2086ca36 -r 4f699653026b src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AbstractAsyncSSLConnection.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AbstractAsyncSSLConnection.java Tue Nov 14 15:57:11 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AbstractAsyncSSLConnection.java Tue Nov 14 16:28:52 2017 +0000 @@ -91,9 +91,6 @@ final SSLEngine getEngine() { return engine; } -// @Override -// SSLParameters sslParameters() { return sslParameters; } - private static SSLParameters createSSLParameters(HttpClientImpl client, String serverName, String[] alpn) { diff -r cb1e2086ca36 -r 4f699653026b src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java Tue Nov 14 15:57:11 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java Tue Nov 14 16:28:52 2017 +0000 @@ -340,7 +340,7 @@ // while we build the Http2Connection return Http2Connection.createAsync(e.connection(), client.client2(), - this, e::getBuffer) + this, e::drainLeftOverBytes) .thenCompose((Http2Connection c) -> { c.putConnection(); Stream s = c.getStream(1); diff -r cb1e2086ca36 -r 4f699653026b src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java Tue Nov 14 15:57:11 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java Tue Nov 14 16:28:52 2017 +0000 @@ -56,13 +56,12 @@ private static final System.Logger DEBUG_LOGGER = Utils.getDebugLogger("Http1Exchange"::toString, DEBUG); - final HttpRequestImpl request; // main request + final HttpRequestImpl request; // main request final Http1Request requestAction; private volatile Http1Response response; final HttpConnection connection; final HttpClientImpl client; final Executor executor; - private volatile ByteBuffer buffer; // used for receiving private final Http1AsyncReceiver asyncReceiver; /** Records a possible cancellation raised before any operation @@ -163,7 +162,6 @@ this.operations = new LinkedList<>(); operations.add(headersSentCF); operations.add(bodySentCF); - this.buffer = Utils.EMPTY_BYTEBUFFER; // TODO: need to check left over data? if (connection != null) { this.connection = connection; } else { @@ -327,11 +325,10 @@ return bodyCF; } - ByteBuffer getBuffer() { + ByteBuffer drainLeftOverBytes() { synchronized (lock) { asyncReceiver.stop(); - this.buffer = asyncReceiver.drain(this.buffer); - return this.buffer; + return asyncReceiver.drain(Utils.EMPTY_BYTEBUFFER); } } diff -r cb1e2086ca36 -r 4f699653026b src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java Tue Nov 14 15:57:11 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java Tue Nov 14 16:28:52 2017 +0000 @@ -420,7 +420,7 @@ long start = DEBUGELAPSED ? System.nanoTime() : 0; reference(); try { - debug.log(Level.DEBUG, "ClientImpl (async) send %s", userRequest); + debugelapsed.log(Level.DEBUG, "ClientImpl (async) send %s", userRequest); MultiExchange mex = new MultiExchange<>(userRequest, requestImpl, @@ -462,7 +462,7 @@ long start = DEBUGELAPSED ? System.nanoTime() : 0; reference(); try { - debug.log(Level.DEBUG, "ClientImpl (async) send multi %s", userRequest); + debugelapsed.log(Level.DEBUG, "ClientImpl (async) send multi %s", userRequest); MultiExchange mex = new MultiExchange<>(userRequest, requestImpl, diff -r cb1e2086ca36 -r 4f699653026b src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponseImpl.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponseImpl.java Tue Nov 14 15:57:11 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponseImpl.java Tue Nov 14 16:28:52 2017 +0000 @@ -161,7 +161,7 @@ } // Http1Exchange may have some remaining bytes in its // internal buffer. - Supplier initial = ((Http1Exchange)exchImpl)::getBuffer; + Supplier initial = ((Http1Exchange)exchImpl)::drainLeftOverBytes; rawchan = new RawChannelImpl(exchange.client(), connection, initial); } return rawchan; diff -r cb1e2086ca36 -r 4f699653026b src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainTunnelingConnection.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainTunnelingConnection.java Tue Nov 14 15:57:11 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainTunnelingConnection.java Tue Nov 14 16:28:52 2017 +0000 @@ -76,7 +76,7 @@ "Tunnel failed, got: "+ resp.statusCode())); } else { // get the initial/remaining bytes - ByteBuffer b = ((Http1Exchange)connectExchange.exchImpl).getBuffer(); + ByteBuffer b = ((Http1Exchange)connectExchange.exchImpl).drainLeftOverBytes(); int remaining = b.remaining(); assert remaining == 0: "Unexpected remaining: " + remaining; connected = true;