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

   Fixes [CAMEL-26503](https://issues.apache.org/jira/browse/CAMEL-26503).
   
   ## What was wrong
   
   `VertxPlatformHttpSupport.writeResponse` writes a String, InputStream, 
Buffer or ByteBuffer reply directly. Any other
   body went to `writeResponseAsFallback`, which asks the type converter for an 
InputStream and then a ByteBuffer.
   `NIOConverter` writes an `Integer`, `Long`, `Short`, `Float` or `Double` in 
its binary form, so
   `setBody(constant(42))` replied with the 4 bytes `00 00 00 2A`. A `Boolean`, 
`Character` or enum has no such
   converter, so the reply failed with 500. A `StringBuilder` was written by 
`IOConverter` in the charset of the exchange,
   not the charset of the response `Content-Type`.
   
   ## What changed
   
   - `writeResponse` turns a `CharSequence`, `Number`, `Boolean`, `Character` 
or enum body into its `toString()` before
     the existing branches, so it goes through the String branch and the 
response `Content-Type` charset applies
     (UTF-8 otherwise). This matches camel-undertow (#28910, CAMEL-26140, 
`UndertowHelper.toByteBuffer`).
   - Map, List and other objects are unchanged: they still fail with 500 and 
the "marshal it first" message.
   - Only the Vert.x engine has this code path. camel-platform-http-main uses 
the Vert.x engine, so it gets the fix too.
     No other platform-http engine in this repo.
   
   ## Tests
   
   New `VertxPlatformHttpSingleValueResponseTest` (real Vert.x server, 
rest-assured, like the existing charset test):
   Integer, Long, Double, Boolean, Character and enum replies arrive as text; a 
Character and a StringBuilder are
   written in the `ISO-8859-1` charset the `Content-Type` declares. Before the 
fix all 8 tests failed: Integer, Long and
   Double came back as binary bytes, Boolean, Character and enum as 500, and 
the StringBuilder as UTF-8 (7 bytes, not 5).
   Full module build (`mvn clean install -Psourcecheck`): 171 tests, 0 
failures, 1 skipped.
   
   ## Docs
   
   - New "Response body" section in `platform-http-vertx.adoc` (and its catalog 
copy).
   - Upgrade guide 4.24: a new `camel-platform-http-vertx` entry, next to the 
existing one for that component, because the
     reply bytes change.
   
   ## Not changed
   
   - The `@BodyTypes` of the platform-http endpoint is left as it is. The reply 
description ("text, bytes, a stream or no
     body. A Map or a List fails: marshal it first") is not wrong. Adding the 
`VALUE` carrier would make the YAML
     validator stop warning about a Map or List at the end of a platform-http 
route, because `onlyPayload()` would no longer
     be true. The endpoint is also shared with the Spring Boot engine, which 
lives in another repo.
   - The producer side does not apply: platform-http has no producer that sends 
bodies this way.
   
   _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