--- a/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java Fri Jun 03 13:45:30 2016 +0100
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Http2Connection.java Fri Jun 03 16:28:53 2016 +0100
@@ -367,7 +367,7 @@
Log.logError(t);
closed = true;
client2.deleteConnection(this);
- Collection<Stream> c = streams.values();
+ List<Stream> c = new LinkedList<>(streams.values());
for (Stream s : c) {
s.cancelImpl(t);
}
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java Fri Jun 03 13:45:30 2016 +0100
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java Fri Jun 03 16:28:53 2016 +0100
@@ -30,6 +30,7 @@
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.LinkedList;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
@@ -537,7 +538,7 @@
* getResponseAsync()
*/
- final List<CompletableFuture<HttpResponseImpl>> response_cfs = new LinkedList<>();
+ final List<CompletableFuture<HttpResponseImpl>> response_cfs = new ArrayList<>(5);
@Override
CompletableFuture<HttpResponseImpl> getResponseAsync(Void v) {
@@ -565,17 +566,16 @@
void completeResponse(HttpResponse r) {
HttpResponseImpl resp = (HttpResponseImpl)r;
synchronized (response_cfs) {
- for (CompletableFuture<HttpResponseImpl> cf : response_cfs) {
+ int cfs_len = response_cfs.size();
+ for (int i=0; i<cfs_len; i++) {
+ CompletableFuture<HttpResponseImpl> cf = response_cfs.get(i);
if (!cf.isDone()) {
cf.complete(resp);
response_cfs.remove(cf);
- //responseHeaders = new HttpHeadersImpl(); // for any following header blocks
return;
- } else
- System.err.println("Stream: " + this + " ALREADY DONE");
+ }
}
response_cfs.add(CompletableFuture.completedFuture(resp));
- //responseHeaders = new HttpHeadersImpl(); // for any following header blocks
}
}