aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-09-02 23:03:13 +0200
committerJon Bratseth <bratseth@gmail.com>2020-09-02 23:03:13 +0200
commit938bec2e2a15876b480e3d76c456ccfc7b7ecdda (patch)
tree0244faad93b85d1d65516b7cb0b71cbe3138888a /vespa-http-client
parent242aa3591ee14481a43157f992f0995bdf2864a3 (diff)
Remove in a supported way
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java7
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java3
2 files changed, 4 insertions, 6 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
index 20d85dc1e2b..7bd0918eb74 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
@@ -561,13 +561,13 @@ public class IOThread implements Runnable, AutoCloseable {
}
public void checkOldConnections() {
- for (Iterator<GatewayConnection> i = connections.iterator(); i.hasNext(); ) {
- GatewayConnection connection = i.next();
+ List<GatewayConnection> toRemove = new ArrayList<>();
+ for (GatewayConnection connection : connections) {
if (closingTime(connection).isBefore(clock.instant())) {
try {
IOThread.processResponse(connection.poll(), endpoint, clusterId, statusReceivedCounter, resultQueue);
connection.close();
- i.remove();
+ toRemove.add(connection);
} catch (Exception e) {
// Old connection; best effort
}
@@ -579,6 +579,7 @@ public class IOThread implements Runnable, AutoCloseable {
}
}
}
+ connections.removeAll(toRemove);
}
private boolean timeToPoll(GatewayConnection connection) {
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
index e684c929fda..c5913d73d7b 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
@@ -1,9 +1,6 @@
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.client.core.communication;
-import com.yahoo.vespa.http.client.FeedClient;
-import com.yahoo.vespa.http.client.FeedEndpointException;
-import com.yahoo.vespa.http.client.Result;
import com.yahoo.vespa.http.client.core.OperationProcessorTester;
import com.yahoo.vespa.http.client.core.ServerResponseException;
import org.junit.Test;