Skip to content

Commit fd1a624

Browse files
authored
Reset network creation state if network creation fails (#6668)
This allows any `startAttempts` that the user has applied to the container to retry the creation of the network too. Fix #6667 Signed-off-by: kwall <[email protected]>
1 parent fa0d237 commit fd1a624

File tree

1 file changed

+9
-2
lines changed
  • core/src/main/java/org/testcontainers/containers

1 file changed

+9
-2
lines changed

core/src/main/java/org/testcontainers/containers/Network.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,16 @@ class NetworkImpl extends ExternalResource implements Network {
5959
@Override
6060
public synchronized String getId() {
6161
if (initialized.compareAndSet(false, true)) {
62-
id = create();
62+
boolean success = false;
63+
try {
64+
id = create();
65+
success = true;
66+
} finally {
67+
if (!success) {
68+
initialized.set(false);
69+
}
70+
}
6371
}
64-
6572
return id;
6673
}
6774

0 commit comments

Comments
 (0)