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

   Fixes [CAMEL-26190](https://issues.apache.org/jira/browse/CAMEL-26190).
   
   ## What was wrong
   
   `JGroupsProducer.process` wrapped the body as is in an `ObjectMessage`, 
which Java-serializes it. A body that is not `Serializable` failed with a 
`RuntimeException` caused by a `NotSerializableException` naming the class, 
with no hint what to do. This hit common bodies:
   
   - a stream cache (stream caching is on by default, so any stream body), an 
`InputStream` or a `Reader`;
   - a file from the `file` component (`GenericFile` is not `Serializable`), 
and a `java.nio.file.Path`. The catalog lists `file` as a body the producer 
takes.
   
   ## What changed
   
   - A stream (`StreamCache`, `InputStream`, `Reader`), a `WrappedFile` (the 
`GenericFile` of the file consumers) and a `Path` are converted to a `byte[]` 
of their content before sending. The other members receive a `byte[]`, which 
the default deserialization filter of the consumer accepts.
   - Any other body that is neither `Serializable` nor a JGroups 
`SizeStreamable` fails with an `InvalidPayloadException` with the hint "the 
body is Java-serialized into the JGroups message, so convert it first, for 
example to a String or a byte[]".
   - Bodies that are `Serializable` are sent as before, unchanged. That 
includes `java.io.File`, which is still sent as a `File` object (its path), not 
its content.
   
   ## Tests
   
   New `JGroupsProducerBodyTest` (7 tests, a Camel `jgroups` consumer in the 
same JVM receives the messages): stream cache, stream cache still readable 
after the send, plain `InputStream`, `Reader`, a file from the `file` consumer, 
a `Path`, and a non-`Serializable` POJO failing with the hint. With the fix 
reverted, the first six fail with `NotSerializableException` and the last gets 
a `RuntimeException` instead of `InvalidPayloadException`. Module suite: 45 
tests, all pass (`mvn clean install -Psourcecheck`).
   
   ## Docs and generated files
   
   - `@BodyTypes` producerIn: adds the `stream` carrier and describes the new 
behaviour; regenerated `jgroups.json` and copied it to the catalog.
   - `jgroups-component.adoc`: a paragraph on which bodies are sent and how; 
catalog doc copy updated.
   - Upgrade guide 4.24: short entry, since the members now receive a `byte[]` 
for such bodies and the exception type of a non-`Serializable` body changed.
   
   ## Not changed
   
   - A `Serializable` body whose object graph holds something that is not 
`Serializable` (for example a `Map` with a stream value) still fails inside 
JGroups with `NotSerializableException`.
   - `java.io.File` is not converted to its content, to keep the current 
behaviour for anyone sending file references.
   
   _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