Dhairya-007 opened a new pull request, #31069: URL: https://github.com/apache/camel/pull/31069
# Rationale for this change [CAMEL-20997](https://issues.apache.org/jira/browse/CAMEL-20997) asks for a review of tests that can block, naming `latch.await()` and "using locks without defining a maximum await time" specifically. These three concurrency tests each park a worker on an unbounded wait: | File | Wait | | --- | --- | | `ManagedPerformanceCounterTest#testConcurrentExchangesAreAllCounted` | `start.await()` | | `StatisticMinimumMaximumTest#testConcurrentUpdates` | `start.await()` | | `SimpleBackOffTimerTest#testCancelWhileCompletionCallbackWaitsForLock` | `ownerHoldsLock.await()` | **To be accurate about the severity:** none of these hangs a CI run today. The two `camel-management` tests bound the *main* thread with `future.get(30, TimeUnit.SECONDS)`, and all three shut their executor down with `shutdownNow()` in a `finally`, which interrupts a parked worker. So the unbounded wait is a latent smell rather than a live hang. What it costs is the failure mode. If a start gate is never opened, the worker parks silently and the test reports `TimeoutException` from `future.get` 30 seconds later — pointing at the wrong thing. With a bounded wait, the test fails in 10 seconds and says which wait never completed. This also brings the three in line with `CLAUDE.md`, which requires an explicit `atMost`-style bound on every asynchronous wait in a test, on the grounds that CI runs them under high concurrency on loaded machines. ## What changed The two `camel-management` tests get an assertion on the bounded wait: ```java assertTrue(start.await(10, TimeUnit.SECONDS), "the start gate was never opened"); ``` Both already import `assertTrue` and `TimeUnit`, and the task is submitted as a `Callable`, so a failed assertion surfaces through the existing `future.get(...)` as an `ExecutionException` instead of being swallowed. `SimpleBackOffTimerTest` deliberately does **not** use an assertion. That wait runs inside a `BackOffTimer` task callback on the timer thread, where a thrown `AssertionError` would be routed into the task's completion handler and change what the test is exercising. It fails loudly without pulling the assertion framework onto that thread: ```java if (!ownerHoldsLock.await(10, TimeUnit.SECONDS)) { throw new IllegalStateException("the owner never took the lock"); } ``` 10 seconds is well clear of what these need — the gate opens on the next statement in the happy path — while staying generous for a loaded machine, per the `CLAUDE.md` guidance to keep timeouts at 10-30 seconds. No production code is touched, and no test assertion or timing expectation changes. ## Are these changes tested? Yes — the affected classes were run locally on JDK 21: ```console $ ./mvnw -pl core/camel-util test -Dtest=SimpleBackOffTimerTest Tests run: 6, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS $ ./mvnw -pl core/camel-management test -Dtest='ManagedPerformanceCounterTest,StatisticMinimumMaximumTest' Tests run: 6, Failures: 0, Errors: 0, Skipped: 0 -- StatisticMinimumMaximumTest Tests run: 11, Failures: 0, Errors: 0, Skipped: 0 -- ManagedPerformanceCounterTest Tests run: 17, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS ``` `StatisticMinimumMaximumTest#testConcurrentUpdates` is a `@RepeatedTest(5)`, so the bounded gate is exercised five times per run. `formatter:format` and `impsort:sort` ran as part of these module builds and left the files unchanged. ## Are there any user-facing changes? No. Test-only. ## Note on the JIRA ticket CAMEL-20997 is still Open and unassigned. `CLAUDE.md` asks an agent to assign the ticket to the operator and move it to In Progress before starting; I could not do that, as I have no ASF JIRA account. The ticket is broad (it covers tests across the whole project), so this PR is one slice of it and does not resolve it — please leave it open. --- _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]
