--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java Mon Nov 13 11:05:52 2017 +0300
@@ -461,8 +461,8 @@
sb.append("socket://")
.append(proxyAddress.getHostString()).append(":")
.append(proxyAddress.getPort());
- String urlstring = sb.toString();
- return new URLPermission(urlstring.toString(), "CONNECT");
+ String urlString = sb.toString();
+ return new URLPermission(urlString, "CONNECT");
}
/**
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1AsyncReceiver.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1AsyncReceiver.java Mon Nov 13 11:05:52 2017 +0300
@@ -362,7 +362,7 @@
// Used for debugging only!
long remaining() {
- return Utils.remaining(queue.toArray(new ByteBuffer[0]));
+ return Utils.remaining(queue.toArray(Utils.EMPTY_BB_ARRAY));
}
void unsubscribe(Http1AsyncDelegate delegate) {
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java Mon Nov 13 11:05:52 2017 +0300
@@ -165,7 +165,7 @@
if (pending == null) pending = new ArrayList<>();
pending.add(buf);
debug.log(Level.DEBUG, () -> "there are now "
- + Utils.remaining(pending.toArray(new ByteBufferReference[0]))
+ + Utils.remaining(pending.toArray(Utils.EMPTY_BBR_ARRAY))
+ " bytes buffered waiting for preface to be sent");
return false;
}
@@ -184,7 +184,7 @@
if (pending != null) {
// flush pending data
debug.log(Level.DEBUG, () -> "Processing buffered data: "
- + Utils.remaining(pending.toArray(new ByteBufferReference[0])));
+ + Utils.remaining(pending.toArray(Utils.EMPTY_BBR_ARRAY)));
for (ByteBufferReference b : pending) {
decoder.decode(b);
}
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseSubscribers.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseSubscribers.java Mon Nov 13 11:05:52 2017 +0300
@@ -138,7 +138,7 @@
@Override
public void onNext(List<ByteBuffer> items) {
try {
- out.write(items.toArray(new ByteBuffer[0]));
+ out.write(items.toArray(Utils.EMPTY_BB_ARRAY));
} catch (IOException ex) {
Utils.close(out);
subscription.cancel();
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java Mon Nov 13 11:05:52 2017 +0300
@@ -419,11 +419,8 @@
// Put all these static 'empty' singletons here
public static final ByteBuffer EMPTY_BYTEBUFFER = ByteBuffer.allocate(0);
public static final ByteBuffer[] EMPTY_BB_ARRAY = new ByteBuffer[0];
- public static final List<ByteBuffer> EMPTY_BB_LIST;
-
- static {
- EMPTY_BB_LIST = Collections.unmodifiableList(new LinkedList<>());
- }
+ public static final List<ByteBuffer> EMPTY_BB_LIST = List.of();
+ public static final ByteBufferReference[] EMPTY_BBR_ARRAY = new ByteBufferReference[0];
public static ByteBuffer slice(ByteBuffer buffer, int amount) {
ByteBuffer newb = buffer.slice();
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesDecoder.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesDecoder.java Mon Nov 13 11:05:52 2017 +0300
@@ -289,7 +289,7 @@
bytecount -= extract;
nextBuffer();
}
- return res.toArray(new ByteBufferReference[0]);
+ return res.toArray(Utils.EMPTY_BBR_ARRAY);
}
public void skipBytes(int bytecount) {
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesEncoder.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesEncoder.java Mon Nov 13 11:05:52 2017 +0300
@@ -26,6 +26,7 @@
package jdk.incubator.http.internal.frame;
import jdk.incubator.http.internal.common.ByteBufferReference;
+import jdk.incubator.http.internal.common.Utils;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -49,7 +50,7 @@
for (HeaderFrame f : frames) {
refs.addAll(Arrays.asList(encodeFrame(f)));
}
- return refs.toArray(new ByteBufferReference[0]);
+ return refs.toArray(Utils.EMPTY_BBR_ARRAY);
}
public ByteBufferReference encodeConnectionPreface(byte[] preface, SettingsFrame frame) {
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java Fri Nov 10 18:22:50 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java Mon Nov 13 11:05:52 2017 +0300
@@ -147,8 +147,8 @@
sb.append("socket://")
.append(proxyAddress.getHostString()).append(":")
.append(proxyAddress.getPort());
- String urlstring = sb.toString();
- return new URLPermission(urlstring.toString(), "CONNECT");
+ String urlString = sb.toString();
+ return new URLPermission(urlString, "CONNECT");
}
/**