davsclaus opened a new pull request, #29014: URL: https://github.com/apache/camel/pull/29014
Fixes [CAMEL-26188](https://issues.apache.org/jira/browse/CAMEL-26188). ### 1. A stream or file body was published as its toString **What was wrong:** `CometdBinding.createCometdMessage` set the body as is as the Bayeux data. A stream (a stream cache, an `InputStream`, a `Reader`) reached the clients as `ByteArrayInputStreamCache@...`, and a `File` as its path. No conversion, no error. **What changed:** a `StreamCache`, `InputStream`, `Reader`, `File`, `Path` or `WrappedFile` (the body of the file consumer) body is converted to a `String` before publishing. The same method builds the reply of an InOut cometd consumer, so that reply is fixed too. ### 2. A null body published nothing the client received **What was wrong:** with a null body, `setData(null)` removes the `data` field. A non-meta message without `data` is a publish reply for the CometD client (`isPublishReply()`), so subscribers never got it, and the exchange succeeded. **What changed:** the `data` field is set to a JSON `null`. The subscribed clients now receive a message with null data. This matches the consumer side, which already takes null data from a client. ### Tests New `CometdProducerBodyTest` with a `BayeuxClient` over loopback: text (unchanged), `InputStream`, stream cache, `Reader`, `File` and `Path`, a file consumer body, a null body, and the InOut consumer reply with a stream and with null. 8 of the 9 tests failed before the fix (only the text body passed). Module: 44 tests, all pass, with `-Psourcecheck`. ### Docs and generated files - `@BodyTypes` of the endpoint: producerIn and consumerReply list stream, file and null, and the descriptions say how they are sent. Regenerated `cometd.json` / `cometds.json` and copied them into the catalog. - Upgrade guide 4.24: new `camel-cometd` entry (stream/file bodies now published as text, a cometd consumer in the same JVM now gets a `String` for them; a null body is now delivered). ### Not changed - A `byte[]` body is still sent as a JSON array of numbers, as the body types already document. Converting bytes to text would guess a charset for binary data. - A null body is not turned into a failure: the issue proposed either; publishing JSON null is the plain mapping and needs no new option. _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]
