gnodet commented on code in PR #24448:
URL: https://github.com/apache/camel/pull/24448#discussion_r3527658886


##########
components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/BackpressureStrategyTest.java:
##########
@@ -145,12 +155,14 @@ public void onNext(Integer o) {
         context().start();
 
         assertTrue(latch.await(5, TimeUnit.SECONDS));
-        Thread.sleep(1000); // wait for all numbers to be generated
+        // Wait for all 20 timer events to be processed
+        await().atMost(5, TimeUnit.SECONDS).until(() -> timerCount.get() >= 
20);
 
         subscriber.request(19);
-        assertTrue(latch2.await(1, TimeUnit.SECONDS));
-        Thread.sleep(200); // add other time to ensure no other items arrive
-        assertEquals(2, queue.size());
+        assertTrue(latch2.await(2, TimeUnit.SECONDS));
+        // Verify exactly 2 items received and no more arrive
+        await().atMost(2, TimeUnit.SECONDS)
+                .untilAsserted(() -> assertEquals(2, queue.size()));

Review Comment:
   Good catch! Fixed in 2b503ed — replaced `await().untilAsserted()` with 
`await().during(500ms).until(() -> queue.size() == 2)` which verifies that the 
queue size remains stable at 2 for 500ms, ensuring no extra items erroneously 
arrive.
   
   _Claude Code on behalf of Guillaume Nodet_



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