aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2020-09-28 17:39:06 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2020-09-28 17:40:52 +0200
commitd0fe7efc633ec1a24a42c9b7feaebf20bbec98ca (patch)
treea0a26488903a12b155fc78c2f27222230b413cf6 /vespa-http-client
parent42a394fae6e97c6791a68078275b259177a7cccb (diff)
Force close if draining fails after connection deadline
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) {