Force close if draining fails after connection deadline
@@ -572,16 +572,21 @@ public class IOThread implements Runnable, AutoCloseable {
public void checkOldConnections() {
List<GatewayConnection> toRemove = null;
+ 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);
- } catch (Exception e) {
- // Old connection; best effort
}
} else if (timeToPoll(connection)) {
try {
@@ -591,8 +596,11 @@ public class IOThread implements Runnable, AutoCloseable {
}
}
}
+ } finally {
if (toRemove != null)
connections.removeAll(toRemove);
+
+ }
}
private boolean timeToPoll(GatewayConnection connection) {
