From 5d8a6ab3a0e19f63171ee197cc16bd79965985b7 Mon Sep 17 00:00:00 2001 From: Philipp Zehnder Date: Tue, 11 Nov 2025 16:19:54 +0100 Subject: [PATCH 1/2] fix: clear queue on connection failure --- .../apache/plc4x/java/utils/cache/ConnectionContainer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java b/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java index a40e722699..097824c9d3 100644 --- a/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java +++ b/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java @@ -152,6 +152,7 @@ public synchronized void returnConnection(LeasedPlcConnection returnedLeasedConn // If something goes wrong, close all waiting futures exceptionally. LOGGER.warn("Can't get connection for {} complete queue items exceptionally", connectionUrl, e); queue.forEach(future -> future.completeExceptionally(e)); + queue.clear(); connection = null; } } @@ -178,6 +179,9 @@ public void run() { return; } + + + // Create a new lease and complete the next future in the queue with this. leasedConnection = new LeasedPlcConnection(this, connection, maxLeaseTime); CompletableFuture leaseFuture = queue.poll(); From 07bcc511d139e835fd73dd245598907e4b3f6688 Mon Sep 17 00:00:00 2001 From: Philipp Zehnder Date: Tue, 11 Nov 2025 16:31:35 +0100 Subject: [PATCH 2/2] fix: remove unnecessary whitespace in ConnectionContainer --- .../org/apache/plc4x/java/utils/cache/ConnectionContainer.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java b/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java index 097824c9d3..b6abef30e0 100644 --- a/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java +++ b/plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/ConnectionContainer.java @@ -179,9 +179,6 @@ public void run() { return; } - - - // Create a new lease and complete the next future in the queue with this. leasedConnection = new LeasedPlcConnection(this, connection, maxLeaseTime); CompletableFuture leaseFuture = queue.poll();