allthingssecurity opened a new pull request, #27244: URL: https://github.com/apache/camel/pull/27244
# Description [CAMEL-25247](https://issues.apache.org/jira/browse/CAMEL-25247) `ThriftMethodHandler` did not handle a failed exchange: - **Asynchronous server (default).** The completion callback called `callback.onError(exception)` and then fell through to `callback.onComplete(response)`, so two results were written for one call (for a `void` method or any method whose generated `onComplete` can write a result; for a primitive return type whose failed body converts to `null` the generated code fails on unboxing before writing, which is why the asynchronous `calculate` case passes on main). With a framed client on one connection, a failing `void ping()` returned normally and the `TApplicationException` meant for it was read as the answer to the next call (`add(12, 13)` failed with "Forced"). - **Synchronous server (`synchronous=true`).** The exception of the exchange was never checked: a `void` method returned normally, other methods returned the body of the failed exchange converted to the return type or, when it did not convert, failed with `Return type requires not empty body`, and an exception declared in the IDL (`InvalidOperation`) never reached the client as such. This change: the synchronous handler throws the exception of the exchange (the Thrift processor writes a declared exception as such, anything else as `TApplicationException`); the asynchronous callback completes the call exactly once, with `onError` when the exchange failed, otherwise with `onComplete` (the "return type"/"null message" errors return as well instead of falling through). The upgrade guide for 4.23 gets a note. Tests: - `ThriftConsumerExceptionTest` (new, 4 tests): declared exception and failing void method on the synchronous and the asynchronous server, each followed by another call on the same connection for the asynchronous one. - Without the change three of them fail (`expected: <InvalidOperation> but was: <TApplicationException>`, `Expected TApplicationException to be thrown, but nothing was thrown`, and `add(12, 13)` throwing `TApplicationException: Forced`). - With the change all camel-thrift tests pass: 45 tests, 0 failures. # 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). # 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 and tested the affected module, including the formatter and import-sort plugins. 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]
