Skip to content

Commit ada816c

Browse files
edee111Eduard Tomek
andauthored
Removal of containers from the cache is not synchronized (#4598)
Co-authored-by: Eduard Tomek <[email protected]>
1 parent 5533447 commit ada816c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ private Connection wrapConnection(final Connection connection, final JdbcDatabas
162162
return new ConnectionWrapper(connection, () -> {
163163
finalConnections.remove(connection);
164164
if (!isDaemon && finalConnections.isEmpty()) {
165-
container.stop();
166-
jdbcUrlContainerCache.remove(connectionUrl.getUrl());
165+
synchronized (jdbcUrlContainerCache) {
166+
container.stop();
167+
jdbcUrlContainerCache.remove(connectionUrl.getUrl());
168+
}
167169
}
168170
});
169171
}

0 commit comments

Comments
 (0)