davsclaus opened a new pull request, #29753: URL: https://github.com/apache/camel/pull/29753
Fixes https://issues.apache.org/jira/browse/CAMEL-26012 ## What The `pulsar` producer sends the body as a `byte[]`. When the body did not convert to one, it fell back to Java serialization (`PulsarMessageUtils.serialize`): a `Map`, a `List`, a number or a `Serializable` POJO was sent as Java-serialized bytes (`AC ED 00 05 ...`), which only a Java client that deserializes them can read, and no body was sent as the five bytes of a serialized `null`. A POJO that is not `Serializable` failed with a `NotSerializableException`. Now: - text, bytes, a stream and a file are sent as their content, as before; - any other body fails with an `InvalidPayloadException` that names the type and says to marshal it first (for example `marshal().json()`); - **no body fails too.** That matches what CAMEL-25956 / #28372 did for the google-pubsub producer ("a serialized null is not a message anybody can use"). Pulsar does support null values (tombstones, which the consumer already hands over as a null body), but sending a tombstone for a missing body would silently delete the key on a compacted topic; that can be a separate opt-in later if someone asks for it; - the new option `allowJavaSerializedObject` (`producer,advanced`, `security = "insecure:serialization"`, `@Deprecated` with a `deprecationNote` from the start) turns the old fallback back on, null included. It is meant to be removed in a later release. ## Changed default This changes the behaviour for routes that send a `Map`, `List`, number, POJO or no body to `pulsar:`. The upgrade guide for 4.24 has an entry ("camel-pulsar - the producer no longer sends a body with Java serialization"). Unlike google-pubsub, which kept its pluggable serializer, pulsar has no serializer option, so the fallback is turned off rather than kept behind a default serializer. ## Also - `@BodyTypes` producerIn description updated, with `dependsOn = "allowJavaSerializedObject"`. - New "Message body" section on the component page. - `PulsarProducerInIT` and `PulsarProducerURIClientIT` sent the `Integer` 10, which relied on the serialization fallback; they now send `"10"`. ## Tests - New `PulsarProducerBodyTest` (mocked client): text, bytes, stream and file are sent as their content; a `Map`, a `Serializable` POJO and no body fail with `InvalidPayloadException` and nothing is sent; with `allowJavaSerializedObject=true` a `Map` is sent as Java-serialized bytes that deserialize to the same map, and text is still sent as its bytes. - Whole module locally, including the ITs against the Pulsar container: all green. Generated files regenerated (component JSON, configurers, catalog, endpoint and component DSL). _Claude Code on behalf of 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]
