8158651: ConcurrentModification exceptions in httpclient
Reviewed-by: rriggs
This commit is contained in:
parent
05e9b6b110
commit
b1c5f2dfdd
@ -367,7 +367,7 @@ class Http2Connection implements BufferHandler {
|
||||
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);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.io.IOException;
|
||||
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 @@ class Stream extends ExchangeImpl {
|
||||
* 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 @@ class Stream extends ExchangeImpl {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user