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

   ## Motivation
   
   [CAMEL-24594](https://issues.apache.org/jira/browse/CAMEL-24594): when the 
REST DSL response binding (`bindingMode(json)` / `xml`) fails to marshal the 
response body, the failure is genuinely invisible.
   
   Response marshalling happens in `RestBindingAdvice#after` (i.e. **after** 
routing has completed), so the exception is not routed through the error 
handler. Unlike an in-route exception — which `DefaultErrorHandler` still logs 
with a stacktrace even when the status is masked to 200 — a marshal failure was 
**not logged at any level**. That is the only Camel failure path where the 
error is completely silent, and it is what made a downstream serialization 
failure take a full day to diagnose after a platform upgrade.
   
   Per the discussion on the ticket (thanks @jamesnetherton), this PR **narrows 
the fix to logging only** and deliberately makes **no change to response-code 
behaviour**:
   
   - An explicitly set `HTTP_RESPONSE_CODE` continues to win over a failed 
exchange, consistent with plain routes — people rely on this.
   - Hardening `RestBindingAdvice#marshal` to force `HTTP_RESPONSE_CODE=500` 
was considered and **rejected**, because it would make the REST binding 
inconsistent with every other failure path and override a code the user 
deliberately set.
   
   ## Changes
   
   - `RestBindingAdvice#marshal` now logs the marshalling failure at `WARN` 
(with stacktrace) before setting the exception on the exchange, bringing the 
post-routing binding step in line with how every other failure in Camel 
surfaces.
   - Extended `VertxRestBindingMarshalFailureTest` with a variant whose 
processor sets `HTTP_RESPONSE_CODE=200` before the failing marshal, pinning 
that the explicitly set code still wins (and the failure is logged rather than 
masking the code).
   
   ## Testing
   
   `VertxRestBindingMarshalFailureTest` — 3 tests, all green.
   
   ---
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 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]

Reply via email to