--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AbstractAsyncSSLConnection.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AbstractAsyncSSLConnection.java Fri Nov 10 18:22:50 2017 +0300
@@ -76,7 +76,7 @@
super(addr, client);
this.serverName = serverName;
SSLContext context = client.theSSLContext();
- sslParameters = createSSLParameters(client, context, serverName, alpn);
+ sslParameters = createSSLParameters(client, serverName, alpn);
Log.logParams(sslParameters);
engine = createEngine(context, sslParameters);
}
@@ -95,7 +95,6 @@
// SSLParameters sslParameters() { return sslParameters; }
private static SSLParameters createSSLParameters(HttpClientImpl client,
- SSLContext context,
String serverName,
String[] alpn) {
SSLParameters sslp = client.sslParameters();
@@ -184,13 +183,10 @@
// It should be removed when RawChannelImpl moves to using asynchronous APIs.
@Override
DetachedConnectionChannel detachChannel() {
- HttpClientImpl client = client();
- assert client != null;
+ assert client() != null;
DetachedConnectionChannel detachedChannel = plainConnection().detachChannel();
SSLDelegate sslDelegate = new SSLDelegate(engine,
- detachedChannel.channel(),
- client,
- serverName);
+ detachedChannel.channel());
return new SSLConnectionChannel(detachedChannel, sslDelegate);
}
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java Fri Nov 10 18:22:50 2017 +0300
@@ -104,10 +104,6 @@
}
}
- ConnectionPool() {
- this("ConnectionPool(?)");
- }
-
ConnectionPool(long clientId) {
this("ConnectionPool("+clientId+")");
}
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java Fri Nov 10 18:22:50 2017 +0300
@@ -167,7 +167,7 @@
if (connection != null) {
this.connection = connection;
} else {
- InetSocketAddress addr = request.getAddress(client);
+ InetSocketAddress addr = request.getAddress();
this.connection = HttpConnection.getConnection(addr, client, request, HTTP_1_1);
}
this.requestAction = new Http1Request(request, this);
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java Fri Nov 10 18:22:50 2017 +0300
@@ -310,7 +310,7 @@
Http2ClientImpl h2client) {
assert request.secure();
AbstractAsyncSSLConnection connection = (AbstractAsyncSSLConnection)
- HttpConnection.getConnection(request.getAddress(h2client.client()),
+ HttpConnection.getConnection(request.getAddress(),
h2client.client(),
request,
HttpClient.Version.HTTP_2);
@@ -860,13 +860,13 @@
* Creates Stream with given id.
*/
final <T> Stream<T> createStream(Exchange<T> exchange) {
- Stream<T> stream = new Stream<>(client(), this, exchange, windowController);
+ Stream<T> stream = new Stream<>(this, exchange, windowController);
return stream;
}
<T> Stream.PushedStream<?,T> createPushStream(Stream<T> parent, Exchange<T> pushEx) {
PushGroup<?,T> pg = parent.exchange.getPushGroup();
- return new Stream.PushedStream<>(pg, client(), this, parent, pushEx);
+ return new Stream.PushedStream<>(pg, this, pushEx);
}
<T> void putStream(Stream<T> stream, int streamid) {
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java Fri Nov 10 18:22:50 2017 +0300
@@ -217,16 +217,16 @@
private static Proxy retrieveProxy(ProxySelector ps, URI uri) {
Proxy proxy = null;
List<Proxy> pl = ps.select(uri);
- if (pl.size() > 0) {
+ if (!pl.isEmpty()) {
Proxy p = pl.get(0);
- if (p.type().equals(Proxy.Type.HTTP))
+ if (p.type() == Proxy.Type.HTTP)
proxy = p;
}
return proxy;
}
InetSocketAddress proxy() {
- if (proxy == null || !proxy.type().equals(Proxy.Type.HTTP)
+ if (proxy == null || proxy.type() != Proxy.Type.HTTP
|| method.equalsIgnoreCase("CONNECT")) {
return null;
}
@@ -287,7 +287,7 @@
systemHeaders.setHeader(name, value);
}
- InetSocketAddress getAddress(HttpClientImpl client) {
+ InetSocketAddress getAddress() {
URI uri = uri();
if (uri == null) {
return authority();
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PushGroup.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PushGroup.java Fri Nov 10 18:22:50 2017 +0300
@@ -133,18 +133,11 @@
});
}
- synchronized CompletableFuture<HttpResponse<T>> mainResponse() {
- return mainResponse;
- }
-
synchronized void addPush() {
numberOfPushes++;
remainingPushes++;
}
- synchronized int numberOfPushes() {
- return numberOfPushes;
- }
// This is called when the main body response completes because it means
// no more PUSH_PROMISEs are possible
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java Fri Nov 10 18:22:50 2017 +0300
@@ -84,9 +84,8 @@
private URI getRedirectedURI(HttpHeaders headers) {
URI redirectedURI;
- String ss = headers.firstValue("Location").orElse("Not present");
redirectedURI = headers.firstValue("Location")
- .map((s) -> URI.create(s))
+ .map(URI::create)
.orElseThrow(() -> new UncheckedIOException(
new IOException("Invalid redirection")));
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/SSLDelegate.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/SSLDelegate.java Fri Nov 10 18:22:50 2017 +0300
@@ -49,19 +49,13 @@
final SSLEngine engine;
final EngineWrapper wrapper;
final Lock handshaking = new ReentrantLock();
- final SSLParameters sslParameters;
final SocketChannel chan;
- final HttpClientImpl client;
- final String serverName;
- SSLDelegate(SSLEngine eng, SocketChannel chan, HttpClientImpl client, String sn)
+ SSLDelegate(SSLEngine eng, SocketChannel chan)
{
this.engine = eng;
this.chan = chan;
- this.client = client;
this.wrapper = new EngineWrapper(chan, engine);
- this.sslParameters = engine.getSSLParameters();
- this.serverName = sn;
}
// alpn[] may be null
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java Fri Nov 10 18:22:50 2017 +0300
@@ -107,7 +107,6 @@
*/
protected volatile int streamid;
- long responseContentLen = -1;
long requestContentLen;
final Http2Connection connection;
@@ -284,8 +283,7 @@
}
@SuppressWarnings("unchecked")
- Stream(HttpClientImpl client,
- Http2Connection connection,
+ Stream(Http2Connection connection,
Exchange<T> e,
WindowController windowController)
{
@@ -362,9 +360,11 @@
request, exchange, responseHeaders,
responseCode, HttpClient.Version.HTTP_2);
- this.responseContentLen = responseHeaders
- .firstValueAsLong("content-length")
- .orElse(-1L);
+ /* TODO: review if needs to be removed
+ the value is not used, but in case `content-length` doesn't parse as
+ long, there will be NumberFormatException. If left as is, make sure
+ code up the stack handles NFE correctly. */
+ responseHeaders.firstValueAsLong("content-length");
if (Log.headers()) {
StringBuilder sb = new StringBuilder("RESPONSE HEADERS:\n");
@@ -953,11 +953,11 @@
final HttpRequestImpl pushReq;
HttpResponse.BodyHandler<T> pushHandler;
- PushedStream(PushGroup<U,T> pushGroup, HttpClientImpl client,
- Http2Connection connection, Stream<T> parent,
- Exchange<T> pushReq) {
+ PushedStream(PushGroup<U,T> pushGroup,
+ Http2Connection connection,
+ Exchange<T> pushReq) {
// ## no request body possible, null window controller
- super(client, connection, pushReq, null);
+ super(connection, pushReq, null);
this.pushGroup = pushGroup;
this.pushReq = pushReq.request();
this.pushCF = new MinimalFuture<>();
@@ -1058,9 +1058,11 @@
pushReq, exchange, responseHeaders,
responseCode, HttpClient.Version.HTTP_2);
- this.responseContentLen = responseHeaders
- .firstValueAsLong("content-length")
- .orElse(-1L);
+ /* TODO: review if needs to be removed
+ the value is not used, but in case `content-length` doesn't parse
+ as long, there will be NumberFormatException. If left as is, make
+ sure code up the stack handles NFE correctly. */
+ responseHeaders.firstValueAsLong("content-length");
if (Log.headers()) {
StringBuilder sb = new StringBuilder("RESPONSE HEADERS");
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/HttpHeadersImpl.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/HttpHeadersImpl.java Fri Nov 10 18:22:50 2017 +0300
@@ -53,12 +53,11 @@
public HttpHeadersImpl deepCopy() {
HttpHeadersImpl h1 = new HttpHeadersImpl();
- TreeMap<String,List<String>> headers1 = h1.headers;
Set<String> keys = headers.keySet();
for (String key : keys) {
List<String> vals = headers.get(key);
List<String> vals1 = new ArrayList<>(vals);
- headers1.put(key, vals1);
+ h1.headers.put(key, vals1);
}
return h1;
}
@@ -73,8 +72,4 @@
values.add(value);
headers.put(name, values);
}
-
- public void clear() {
- headers.clear();
- }
}
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java Fri Nov 10 18:22:50 2017 +0300
@@ -320,23 +320,6 @@
return accumulatedBytes;
}
- /**
- * Copy amount bytes from src to dst. at least amount must be
- * available in both dst and in src
- */
- public static void copy(ByteBuffer src, ByteBuffer dst, int amount) {
- int excess = src.remaining() - amount;
- assert excess >= 0;
- if (excess > 0) {
- int srclimit = src.limit();
- src.limit(srclimit - excess);
- dst.put(src);
- src.limit(srclimit);
- } else {
- dst.put(src);
- }
- }
-
public static ByteBuffer copy(ByteBuffer src) {
ByteBuffer dst = ByteBuffer.allocate(src.remaining());
dst.put(src);
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/ErrorFrame.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/ErrorFrame.java Fri Nov 10 18:22:50 2017 +0300
@@ -88,8 +88,4 @@
public int getErrorCode() {
return this.errorCode;
}
-
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- }
}
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/Http2Frame.java Fri Nov 10 16:24:07 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/Http2Frame.java Fri Nov 10 18:22:50 2017 +0300
@@ -49,10 +49,6 @@
flags |= flag;
}
- public void setFlags(int flags) {
- this.flags = flags;
- }
-
public int getFlags() {
return flags;
}
@@ -70,7 +66,7 @@
}
- public String typeAsString() {
+ private String typeAsString() {
return asString(type());
}