gnodet commented on code in PR #31342:
URL: https://github.com/apache/camel/pull/31342#discussion_r4798661686
##########
components/camel-ai/camel-mcp-server-api/src/test/java/org/apache/camel/component/mcp/server/conformance/McpServerResourceConformanceTestSupport.java:
##########
@@ -301,6 +301,14 @@ void
testResourceTemplateLifecycleSendsListChangedNotifications() throws Excepti
try {
notificationClient.initialize();
+ // the client opens its listening stream asynchronously after
initialize, and a notification sent before
+ // that is dropped by the server: toggle the route until one is
received, then the stream is established
+ await().atMost(10, TimeUnit.SECONDS).until(() -> {
Review Comment:
**Approach: Side effects in await() lambda**
This pattern of having side effects (stop/start operations) inside the
`await().until()` lambda is unusual but justified here. Normally Awaitility
lambdas are read-only checks, but in this case you need to actively generate
notifications to verify the stream is working.
**How it works:**
- Awaitility polls every ~100ms (default interval)
- Each iteration does a full stop/start cycle (both are synchronous,
blocking operations)
- Once a notification arrives, `notifications.get() > 0` returns true and
the loop exits
- Multiple stop/start cycles may occur before the stream is ready, which is
fine
This correctly fixes the race condition and follows the project's test
guidelines (no fixed delays, explicit timeout). The validation with the
artificial 3s delay confirms it works correctly.
---
_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]