You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2024/07/06 12:40:26 UTC
(plc4x) branch develop updated: fix: Increased some of the delays in order to hopefully make the tests pass on slower machines.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 6a51166530 fix: Increased some of the delays in order to hopefully make the tests pass on slower machines.
6a51166530 is described below
commit 6a511665309755c49481824f0085796025fdb541
Author: Christofer Dutz <cd...@apache.org>
AuthorDate: Sat Jul 6 14:40:19 2024 +0200
fix: Increased some of the delays in order to hopefully make the tests pass on slower machines.
---
.../org/apache/plc4x/java/utils/cache/ConnectionContainer.java | 6 ++++++
.../plc4x/java/utils/cache/CachedPlcConnectionManagerTest.java | 8 ++++----
2 files changed, 10 insertions(+), 4 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 95ff9ff876..2547651e40 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
@@ -76,6 +76,12 @@ class ConnectionContainer {
} catch (Exception e) {
// Ignore this ...
}
+ } else {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ // Ignore this ...
+ }
}
}
diff --git a/plc4j/tools/connection-cache/src/test/java/org/apache/plc4x/java/utils/cache/CachedPlcConnectionManagerTest.java b/plc4j/tools/connection-cache/src/test/java/org/apache/plc4x/java/utils/cache/CachedPlcConnectionManagerTest.java
index 77b6a190d2..639146c954 100644
--- a/plc4j/tools/connection-cache/src/test/java/org/apache/plc4x/java/utils/cache/CachedPlcConnectionManagerTest.java
+++ b/plc4j/tools/connection-cache/src/test/java/org/apache/plc4x/java/utils/cache/CachedPlcConnectionManagerTest.java
@@ -185,7 +185,7 @@ public class CachedPlcConnectionManagerTest {
PlcConnectionManager mockConnectionManager = Mockito.mock(PlcConnectionManager.class);
Mockito.when(mockConnectionManager.getConnection("test")).thenReturn(mockConnection);
- CachedPlcConnectionManager connectionManager = CachedPlcConnectionManager.getBuilder(mockConnectionManager).withMaxLeaseTime(Duration.ofMillis(30)).build();
+ CachedPlcConnectionManager connectionManager = CachedPlcConnectionManager.getBuilder(mockConnectionManager).withMaxLeaseTime(Duration.ofMillis(300)).build();
// Have multiple leases borrowed.
// The first should get the lease directly but will hang on to it for some time.
@@ -207,7 +207,7 @@ public class CachedPlcConnectionManagerTest {
thread.start();
// Give the thread some time to start up.
- Thread.sleep(10L);
+ Thread.sleep(100L);
// The second will wait in the queue.
CompletableFuture<Void> secondFuture = new CompletableFuture<>();
@@ -224,7 +224,7 @@ public class CachedPlcConnectionManagerTest {
}).start();
// Give the thread some time to start up.
- Thread.sleep(10L);
+ Thread.sleep(100L);
// Check that only one connection has been requested from the PlcConnectionManager.
Mockito.verify(mockConnectionManager, Mockito.times(1)).getConnection("test");
@@ -302,7 +302,7 @@ public class CachedPlcConnectionManagerTest {
connection.close();
// Wait for longer than the max idle time.
- Thread.sleep(20);
+ Thread.sleep(200);
Assertions.assertEquals(0, connectionManager.getCachedConnections().size());
}