Croway opened a new pull request, #24814: URL: https://github.com/apache/camel/pull/24814
## Summary _Claude Code on behalf of Croway_ Fixes [CAMEL-24152](https://issues.apache.org/jira/browse/CAMEL-24152): concurrent `marshal`/`unmarshal` operations corrupt data because all per-thread `Yaml` instances share single `BaseConstructor` and `Representer` singletons created once in `doStart()`. This was a regression introduced by CAMEL-22354 (commit `5dfc5c2857e9`, released in 4.15.0), which replaced `Function<CamelContext, BaseConstructor>` factories with shared singletons while retaining the `ThreadLocal<Yaml>` cache. Since SnakeYAML's `BaseConstructor` and `Representer` are heavily stateful, sharing them across threads causes: 1. Internal SnakeYAML crashes (`IndexOutOfBoundsException`, `ParserException`, `NPE`) 2. Marshal crashes (`NullPointerException` on nodes) 3. Silent cross-thread data bleed (one thread's unmarshal returns another thread's payload) ### Changes - **`SnakeYAMLDataFormat.doStart()`** — Removed default singleton creation for `constructor`, `representer`, `dumperOptions`, `resolver`. - **`SnakeYAMLDataFormat.getYaml()`** — When creating a new `Yaml`, calls `default*()` factory methods to produce fresh per-thread instances instead of reusing shared singletons. User-supplied custom instances (via `setConstructor()` etc.) are still used as-is. - **`SnakeYAMLConcurrentTest`** — New test: 8 threads × 500 marshal/unmarshal round-trips with distinct payloads, asserting no exceptions and no cross-thread data corruption. ## Test plan - [x] `mvn verify` in `components/camel-snakeyaml` — all 19 tests pass (including new concurrency test) - [ ] Verify existing SnakeYAML tests pass in CI (SnakeYAMLTest, SnakeYAMLDoSTest, SnakeYAMLTypeFilterTest, etc.) - [ ] Verify the new concurrent test passes in CI 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
