ammachado opened a new pull request, #23997:
URL: https://github.com/apache/camel/pull/23997

   # Description
   
   Replace three `Thread.sleep` calls in test code with deterministic 
synchronization mechanisms, eliminating fixed-time assumptions that fail on 
loaded CI machines.
   
   **1. `MainListenerTest` (race on background thread initialization)**
   The test started a background `main.run()` thread and slept 100ms hoping 
initialization had completed before calling `main.completed()`. On a slow 
machine the main thread may not have reached `beforeInitialize` yet, causing 
the event list to be incomplete.
   Fix: added a `CountDownLatch(1)` that counts down when the 
`beforeInitialize` event fires. The main thread now waits on the latch (10s 
timeout) before calling `main.completed()`. No new dependency needed.
   
   **2. `ManagedThrottlingExceptionRoutePolicyTest` (brittle JMX propagation 
wait)**
   After inducing a route failure, the test slept 200ms and then asserted 
`proxy.getLastFailure() > 0`. JMX MBean state propagation can take longer than 
200ms under CI load.
   Fix: replaced with `await().atMost(10, TimeUnit.SECONDS).until(() -> 
proxy.getLastFailure() > 0)`. Awaitility is already a test dependency in 
`camel-management`.
   
   **3. `AsyncCompletionServiceTest` (redundant sleep before blocking call)**
   `testSubmitOrderedFirstTaskIsSlow` submitted a 200ms task and slept 300ms 
before calling `service.take()`. The `take()` method already blocks until the 
result is available in submission order, making the sleep entirely redundant. 
The sibling test `testSubmitOrderedFirstTaskIsSlowUsingPollTimeout` 
demonstrates the correct pattern without any sleep.
   Fix: removed the `Thread.sleep(300)` call.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL-21438) 
filed for the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [x] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
   
   ---
   _Claude Code on behalf of Adriano Machado_


-- 
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]

Reply via email to