aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java44
1 files changed, 26 insertions, 18 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 b931a7f2617..aa914f852c3 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
@@ -572,27 +572,35 @@ public class IOThread implements Runnable, AutoCloseable {
public void checkOldConnections() {
List<GatewayConnection> toRemove = null;
- for (GatewayConnection connection : connections) {
- if (closingTime(connection).isBefore(clock.instant())) {
- try {
- IOThread.processResponse(connection.poll(), endpoint, clusterId, statusReceivedCounter, resultQueue);
- connection.close();
- if (toRemove == null)
- toRemove = new ArrayList<>(1);
- toRemove.add(connection);
- } catch (Exception e) {
- // Old connection; best effort
- }
- } else if (timeToPoll(connection)) {
- try {
- IOThread.processResponse(connection.poll(), endpoint, clusterId, statusReceivedCounter, resultQueue);
- } catch (Exception e) {
- // Old connection; best effort
+ try {
+ for (GatewayConnection connection : connections) {
+ if (closingTime(connection).isBefore(clock.instant())) {
+ try {
+ try {
+ IOThread.processResponse(connection.poll(), endpoint, clusterId, statusReceivedCounter, resultQueue);
+ } finally {
+ connection.close();
+ }
+ } catch (Exception e) {
+ // Old connection; best effort
+ } finally {
+ if (toRemove == null)
+ toRemove = new ArrayList<>(1);
+ toRemove.add(connection);
+ }
+ } else if (timeToPoll(connection)) {
+ try {
+ IOThread.processResponse(connection.poll(), endpoint, clusterId, statusReceivedCounter, resultQueue);
+ } catch (Exception e) {
+ // Old connection; best effort
+ }
}
}
+ } finally {
+ if (toRemove != null)
+ connections.removeAll(toRemove);
+
}
- if (toRemove != null)
- connections.removeAll(toRemove);
}
private boolean timeToPoll(GatewayConnection connection) {