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

   JIRA: https://issues.apache.org/jira/browse/CAMEL-26684
   
   ## Problem
   
   
`GrpcRouteControlledReplyTypeTest.delegationUnchangedRequestIsNotSentAsResponse`
 is flaky (added with CAMEL-26515; it already has 1 failure and 2 flaky runs on 
Develocity):
   
   ```
   org.awaitility.core.ConditionTimeoutException: Condition with Lambda 
expression in org.apache.camel.component.grpc.GrpcRouteControlledReplyTypeTest 
was not fulfilled within 5 seconds.
        at 
...GrpcRouteControlledReplyTypeTest.awaitDoneExchanges(GrpcRouteControlledReplyTypeTest.java:231)
        at 
...GrpcRouteControlledReplyTypeTest.delegationUnchangedRequestIsNotSentAsResponse(GrpcRouteControlledReplyTypeTest.java:131)
   ```
   
   ## Cause
   
   The test sends `onNext` and `onCompleted` back to back and expects the 
`rc-delegation-unchanged` route to process two exchanges: the `onNext` one, 
which fails with the reply type error, and the forwarded `onCompleted` one 
(`forwardOnCompleted=true`).
   
   The reply type error closes the call. When that happens before the server 
handled the half-close of the client, the `onCompleted` event is never 
forwarded, so the second exchange never exists and `awaitDoneExchanges` times 
out. This is a race in the test, not in the component.
   
   ## Fix
   
   The order of the events is made deterministic in the test route, and the 
assertions are unchanged (they still check for the two exchanges, the failure 
of the first one, and that the second one does not fail):
   
   - the `onNext` exchange waits, on another thread than the one of the call, 
for the `onCompleted` event to reach the route, so the call is not closed 
before the half-close is handled;
   - the `onCompleted` exchange waits for the `onNext` exchange to have failed 
before it replies, so it is ignored on the closed call as expected.
   
   ## Verification
   
   Reproduced under CPU load (busy loops on 2x the number of cores) with the 
test repeated with `@RepeatedTest`:
   
   | | runs | failures |
   |---|---|---|
   | without the change | 300 | 1 |
   | without the change | 600 | 4 (all the `ConditionTimeoutException` above) |
   | with the change | 300 | 0 |
   | with the change | 600 | 0 |
   
   The whole test class passes (12 tests). No production code is changed, so no 
documentation or upgrade guide entry is needed.
   
   ---
   _Claude Code is not involved; this PR description was AI-generated by IBM 
Bob 2.2.1 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]

Reply via email to