gnodet commented on code in PR #22287:
URL: https://github.com/apache/camel/pull/22287#discussion_r2999943447
##########
test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java:
##########
@@ -114,6 +114,9 @@ public static String containerName(Class cls) {
if (annotation.serviceImplementationAlias().length > 0) {
name += "-" + annotation.serviceImplementationAlias()[0];
}
+ // Append PID to avoid Docker container name conflicts when
multiple
+ // modules run tests in parallel (e.g., via mvnd with multiple
threads)
+ name += "-" + ProcessHandle.current().pid();
Review Comment:
The conflict happens between **separate JVM processes** (mvnd spawns each
module in its own daemon JVM), not between threads within the same JVM. Thread
ID wouldn't help because:
1. Thread IDs are not unique across processes — e.g., both JVMs' main
threads could have thread ID 1
2. Within a single JVM, the `SingletonService` pattern already ensures only
one container is created per service, shared across all test classes/threads
3. Thread ID can vary depending on which thread first triggers the container
creation, making the name non-deterministic within the same JVM — which could
actually *cause* collisions where none exist today
PID is unique per JVM on the host and stable for the entire JVM lifetime,
which is exactly the granularity we need.
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]