You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: NullPointerException from ResourceReaper in GenericContainer.stop #11492
java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
at java.base/java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1125)
at java.base/java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1116)
at org.testcontainers.utility.ResourceReaper.stopAndRemoveContainer(ResourceReaper.java:175)
at org.testcontainers.containers.GenericContainer.stop(GenericContainer.java:652)
at io.trino.tests.product.launcher.env.DockerContainer.reset(DockerContainer.java:411)
at io.trino.tests.product.launcher.env.Environment.tryStart(Environment.java:157)
I took a look at this — the NPE comes from ConcurrentHashMap.remove(null) inside stopAndRemoveContainer(), since ConcurrentHashMap doesn't accept null keys.
One thing I noticed is that GenericContainer.stop() already guards against a null containerId before calling into ResourceReaper, so it's not obvious how null gets through. Could be a race or another caller hitting the deprecated overload.
I'm thinking a simple null check (early return) in both stopAndRemoveContainer() overloads would prevent the crash. The deeper root cause could be investigated separately if needed.
Would that approach work, or would you prefer finding the exact path first?
Activity
PreAgile commentedon Mar 27, 2026
I took a look at this — the NPE comes from
ConcurrentHashMap.remove(null)insidestopAndRemoveContainer(), sinceConcurrentHashMapdoesn't accept null keys.One thing I noticed is that
GenericContainer.stop()already guards against a nullcontainerIdbefore calling intoResourceReaper, so it's not obvious how null gets through. Could be a race or another caller hitting the deprecated overload.I'm thinking a simple null check (early return) in both
stopAndRemoveContainer()overloads would prevent the crash. The deeper root cause could be investigated separately if needed.Would that approach work, or would you prefer finding the exact path first?
radhika4229 commentedon Aug 3, 2026
"Hi, I'd like to work on this if it's still open. Could you share any pointers on reproducing this or which part of ResourceReaper is involved?"