Dhairya-007 opened a new pull request, #31078: URL: https://github.com/apache/camel/pull/31078
# Rationale for this change `DataFormatConcurrentTest` can hang a CI job indefinitely. [CAMEL-20997](https://issues.apache.org/jira/browse/CAMEL-20997) names this shape directly — `latch.await()` with no maximum wait. Both `unmarshal(...)` and `marshal(...)` dispatch 10 000 sends to a 20-thread pool and then wait on the test thread: ```java for (int i = 0; i < payloads.length; i++) { final int finalI = i; pool.execute(new Runnable() { public void run() { template.sendBody(payloads[finalI]); } }); } latch.await(); // unbounded ``` The latch is only counted down by the **last** step of the route: ```java from("direct:unmarshal") .unmarshal(new JaxbDataFormat("org.apache.camel.example")) .process(exchange -> latch.countDown()); ``` So the count only reaches zero if every one of the 10 100 conversions succeeds. If any single JAXB conversion fails, that exchange never reaches the `.process`, the latch never completes, and the test thread stays in `await()` forever. Three things make that failure invisible rather than merely slow: 1. The sends go through `pool.execute`, not `submit`, so the exception goes to the thread's uncaught-exception handler and is dropped — there is no `Future` holding it. 2. The `assertDoesNotThrow(() -> runUnmarshalConcurrent())` wrapper cannot help: the test thread is parked, not throwing. 3. There is no per-test timeout here, so the symptom is the whole job being killed on the overall CI timeout, naming no test and no cause. The pool is also never shut down, so each of the four test methods leaks 20 threads for the lifetime of the fork — which matters given `camel.surefire.forkCount` reuses a fork across many test classes. ## What changed Both methods get a bounded wait and a `finally` that shuts the pool down: ```java try { for (int i = 0; i < payloads.length; i++) { ... } assertTrue(latch.await(2, TimeUnit.MINUTES), "only " + (warmupCount + testCycleCount - latch.getCount()) + " of " + (warmupCount + testCycleCount) + " messages reached the end of the route"); } finally { pool.shutdownNow(); } ``` The message is the point of the change as much as the bound: instead of a job killed on timeout, the failure now says how many of the 10 100 messages actually made it, which immediately distinguishes "a conversion failed" from "this machine is too slow". Two minutes is deliberately generous — 10 100 marshal/unmarshal round trips through a `direct:` route, on a loaded machine, with `CLAUDE.md` asking for 10-30 seconds for ordinary conditions and more where the work warrants it. It only elapses when the test is already broken. I did not convert `pool.execute` to `submit` with `Future` checks. It would surface the underlying exception directly, which is tempting, but it changes how 10 000 tasks are dispatched and collected in a test whose purpose is throughput measurement. The bounded wait plus the count in the message is enough to stop the hang and point at the cause; happy to go further if you would prefer it. ## Are these changes tested? ```console $ ./mvnw -pl components/camel-jaxb test -Dtest=DataFormatConcurrentTest Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.89 s BUILD SUCCESS ``` All five tests pass, so the two-minute bound is nowhere near being hit on a normal run — the whole class takes 13 seconds. `formatter:format` and `impsort:sort` ran as part of that build and left the file unchanged, so the re-indentation inside the new `try` block and the two added imports are already in the project's style. ## Are there any user-facing changes? No. Test-only. ## Note on the JIRA ticket CAMEL-20997 is Open and unassigned, and covers tests across the whole project, so this is one slice and does not resolve it. `CLAUDE.md` asks an agent to assign the ticket and move it to In Progress first; I have no ASF JIRA account, so I could not. --- _Claude Code on behalf of Dhairya-007_ -- 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]
