apupier opened a new pull request, #31342: URL: https://github.com/apache/camel/pull/31342
JIRA: https://issues.apache.org/jira/browse/CAMEL-28102 ## Problem `MainHttpServerMcpResourceConformanceIT.testResourceTemplateLifecycleSendsListChangedNotifications` is flaky (17 flaky runs and 1 failure since 16th November). It fails with `ConditionTimeoutException` at the first `await()` (line 306): no `notifications/resources/list_changed` notification is received within 10 seconds. ## Root cause The test calls `client.initialize()` and immediately stops the `customer-template-route`. The server delivers list-changed notifications through the session's listening stream (`VertxMcpStreamableServerTransportProvider.notifyClients` -> `McpStreamableServerSession.sendNotification`). That stream only exists once the client has issued a separate GET request, which the SDK client does asynchronously after `initialize`. A notification sent before the stream exists is dropped (the SDK session has no listening stream until the GET arrives). On a loaded CI machine the route stop wins the race, and the test never sees a notification. The CI log matches: the route is stopped ~38 ms after the client `initialize`, and no notification follows for the 10 s timeout. ## Reproduction I reproduced the failure deterministically by temporarily widening the gap: a 3 s `Thread.sleep` at the start of `VertxMcpStreamableServerTransportProvider.handleGet` (not part of this PR). | Run | Result | |---|---| | Without the fix, 3 s delay in `handleGet` | `ConditionTimeoutException` at line 306 after 10 s (also on both surefire reruns) | | With the fix, same 3 s delay | `MainHttpServerMcpResourceConformanceIT`: 14 tests, 0 failures | ## Fix Before asserting the stop and start notifications, the test now toggles the route inside an `await().atMost(10, TimeUnit.SECONDS)` until the first notification is received. Receiving one proves the listening stream is established, so the subsequent assertions are no longer racy. No sleeps or fixed delays are used. This is a test-only change in `camel-mcp-server-api` (`McpServerResourceConformanceTestSupport`); no production code is touched. ## Validation - `mvn verify -Pit -Dit.test=MainHttpServerMcpResourceConformanceIT` in `camel-mcp-server`: 14 tests, 0 failures - Same run with the 3 s `handleGet` delay: passes with the fix, fails without it (see above) - `mvn formatter:format impsort:sort`: no changes --- _Claude... no: AI-generated by IBM Bob on behalf of @apupier_ -- 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]
