gnodet opened a new pull request, #27226: URL: https://github.com/apache/camel/pull/27226
## Summary Fixes the flaky `AsyncWiretapTest` in `camel-telemetry` and `camel-telemetry-dev` by replacing non-thread-safe collections in the mock telemetry infrastructure with their concurrent equivalents. Resolves: https://issues.apache.org/jira/browse/CAMEL-24038 ## Root Cause The wiretap EIP creates async exchanges processed on different threads, causing concurrent access on plain `HashMap` and `ArrayList` instances in the mock infrastructure — collections that provide no memory-visibility guarantees across threads. This directly explains the intermittent `expected: <7> but was: <6>` and `expected: <10> but was: <N>` failures seen in CI: spans silently lost due to HashMap's undefined concurrent-modification behavior. Previous fixes (PRs #24636, #25331) addressed timing via Awaitility but not the underlying data-race root cause. This PR fixes the root cause. ## Changes ### `camel-telemetry` (test classes) **`MockTracer.java`** — `MockSpanLifecycleManager.inMemoryStorageMap` - `HashMap` → `ConcurrentHashMap` - `activate()` and `close()` are called from exchange threads; `traces()` is called from the test thread **`MockSpanAdapter.java`** — `tags` and `logEntries` - `HashMap` → `ConcurrentHashMap` for `tags` (the `isDone` tag is written from an exchange thread and read from the test thread without memory barriers) - `ArrayList` → `Collections.synchronizedList` for `logEntries` - Guard `setComponent()` and `setTag()` against null values (ConcurrentHashMap rejects nulls; some decorator tests pass null via Mockito mocks) ### `camel-telemetry-dev` (production class used as test infrastructure) **`DevSpanAdapter.java`** — `tags` and `logEntries` - Same pattern as `MockSpanAdapter`: `HashMap` → `ConcurrentHashMap`, `ArrayList` → `Collections.synchronizedList` - `setLogEntries()` wraps the incoming list in a synchronized wrapper ### Not changed `InMemoryCollector` — already protects all access with a `ReentrantLock` ✓ ## Testing All existing tests in both modules pass locally (`mvn test` on both `camel-telemetry` and `camel-telemetry-dev`). -- 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]
