allthingssecurity opened a new pull request, #30464: URL: https://github.com/apache/camel/pull/30464
# Description [CAMEL-27208](https://issues.apache.org/jira/browse/CAMEL-27208) A gRPC producer with `streamRepliesTo` and the SIMPLE producer strategy (the default) routes the responses of a call to another endpoint with `GrpcResponseRouterStreamObserver`, which also completes the exchange that made the call when the call ends. When the call failed (server not reachable, deadline exceeded, an error status from the server), `onError` completed the exchange without setting the exception. With `forwardOnError=false` (the default) the error was not routed anywhere either: the exchange completed as a success, no error handler or redelivery ran, and nothing was logged. A route such as `from(...).to("grpc://host:port/pkg.Service?method=x&streamRepliesTo=direct:replies")` lost every failed call without a trace. Without `streamRepliesTo` (`GrpcResponseAggregationStreamObserver`) the exchange does fail. Fix: `GrpcResponseRouterStreamObserver.onError` sets the error on the exchange of the call when the error is not routed to the replies endpoint and the producer strategy is SIMPLE. With `forwardOnError=true` the error is routed to the replies endpoint as before and the exchange completes, so the error is handled once, where the route asked for it. With the STREAMING strategy the exchanges are completed when they are sent on the stream, before the stream ends, so nothing changes there. The 4.24 upgrade guide has an entry, as such an exchange now fails. A redelivery of the error handler calls the method again, so the replies that a server-streaming call routed before it failed are routed again by the new call. Not changed (follow-up JIRA if wanted): with the STREAMING strategy the observer of the stream holds the callback of the exchange that opened the stream and calls it again when the stream ends, after the forwarder completed that exchange. I could not see an effect of it in a test (the route after the producer does not run again), so it is left out of this fix. Tests: `GrpcProducerStreamRepliesToTest` (in-JVM gRPC server on a free port, like the other producer tests): a call that the server fails with UNAVAILABLE and a call to a port that nothing listens on must each fail the exchange with a `StatusRuntimeException` of status UNAVAILABLE; a successful call routes its two replies and completes (control); with `forwardOnError=true` the error is routed to the replies endpoint and the exchange completes (control, as before). Runs (offline, with grpc 1.84.2 and java-jwt 4.6.1, the versions cached on my machine): on main the two failure tests fail (the exchange completes without an exception) and the two controls pass; with the fix all four pass; camel-grpc module tests 85 run, 0 failures; the new test class 20 times in one JVM: 80 of 80. # 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) filed for the change (usually before you start working on it): [CAMEL-27208](https://issues.apache.org/jira/browse/CAMEL-27208). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built the core modules and camel-grpc with the formatter and import-sort plugins. No option changed. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
