Skip to content

Commit

Permalink
fix: correct drop of a network for sync container (#612)
Browse files Browse the repository at this point in the history
Network must be dropped only after container, not before
  • Loading branch information
DDtKey authored Apr 29, 2024
1 parent b4d1624 commit 95f67ec
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 1 addition & 2 deletions testcontainers/src/core/containers/async_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ pub struct ContainerAsync<I: Image> {
id: String,
image: RunnableImage<I>,
pub(super) docker_client: Arc<Client>,
#[cfg_attr(not(feature = "blocking"), allow(dead_code))]
pub(super) network: Option<Arc<Network>>,
network: Option<Arc<Network>>,

Check warning on line 36 in testcontainers/src/core/containers/async_container.rs

View workflow job for this annotation

GitHub Actions / clippy

field `network` is never read

warning: field `network` is never read --> testcontainers/src/core/containers/async_container.rs:36:5 | 32 | pub struct ContainerAsync<I: Image> { | -------------- field in this struct ... 36 | network: Option<Arc<Network>>, | ^^^^^^^ | = note: `#[warn(dead_code)]` on by default
dropped: bool,
}

Expand Down
1 change: 0 additions & 1 deletion testcontainers/src/core/containers/sync_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ impl<I: Image> Drop for Container<I> {
fn drop(&mut self) {
if let Some(mut active) = self.inner.take() {

Check warning on line 161 in testcontainers/src/core/containers/sync_container.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

warning: variable does not need to be mutable --> testcontainers/src/core/containers/sync_container.rs:161:21 | 161 | if let Some(mut active) = self.inner.take() { | ----^^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
active.runtime.block_on(async {
drop(active.async_impl.network.take());
match active.async_impl.docker_client.config.command() {
env::Command::Remove => active.async_impl.rm().await,
env::Command::Keep => {}
Expand Down

0 comments on commit 95f67ec

Please sign in to comment.