Skip to content

Conversation

@HofmeisterAn
Copy link
Collaborator

What does this PR do?

This PR fixes a NRE that can occur when a container is created with the auto-remove option and then manually stopped. If Docker removes the container, the _container field is set to a default value that lacks a valid State property. The fix adds a null-conditional operator to safely access State.

While not perfect, the implementation already falls back to UtcNow (for the StoppedTime property), so the behavior is preserved. All other accesses to State were double-checked and are already NRE-safe.

Why is it important?

This change prevents users from encountering unexpected exceptions.

Related issues

@HofmeisterAn HofmeisterAn added the bug Something isn't working label Jul 31, 2025
@netlify
Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit ad5792e
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/688b822683f55b0008983277
😎 Deploy Preview https://deploy-preview-1499--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@HofmeisterAn HofmeisterAn merged commit 9eec936 into develop Jul 31, 2025
137 checks passed
@HofmeisterAn HofmeisterAn deleted the bugfix/fix-nre branch July 31, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Possible NullReferenceExcetion on StoppedTime calculation when DockerContainer.StopAsync is called

2 participants