Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect NetworkImpl#close from concurrency issues #2203

Merged
merged 3 commits into from Apr 12, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/main/java/org/testcontainers/containers/Network.java
Expand Up @@ -52,7 +52,7 @@ class NetworkImpl extends ExternalResource implements Network {
@Singular
private Set<Consumer<CreateNetworkCmd>> createNetworkCmdModifiers;

private String id;
private volatile String id;
bsideup marked this conversation as resolved.
Show resolved Hide resolved

private final AtomicBoolean initialized = new AtomicBoolean();

Expand Down Expand Up @@ -97,7 +97,7 @@ protected void after() {
}

@Override
public void close() {
public synchronized void close() {
if (initialized.getAndSet(false)) {
ResourceReaper.instance().removeNetworkById(id);
}
Expand Down