Claus Ibsen created CAMEL-26005:
-----------------------------------
Summary: camel-jackson-protobuf - protobufJackson writes JSON
text, bytes or a stream as they are and labels them application/protobuf
Key: CAMEL-26005
URL: https://issues.apache.org/jira/browse/CAMEL-26005
Project: Camel
Issue Type: Bug
Components: camel-jackson
Affects Versions: 4.18.0, 4.22.0, 4.23.0
Reporter: Claus Ibsen
Fix For: 4.24.0
JacksonProtobufDataFormat extends JacksonDataFormat
({{JacksonProtobufDataFormat}}, main 56aa5f4970a6, line 32). It therefore
inherits the JSON as-is shortcut of CAMEL-25329 (4.23.0): JacksonDataFormat
writes a body that is already JSON unchanged
({{JsonPayloadHelper.writeIfAlreadyJson}}, {{JacksonDataFormat}} line 124).
Such a body is a byte[], a stream, a file, or a String with a JSON object or
array. For protobufJackson, that body is written to the protobuf output and
labelled {{Content-Type: application/protobuf}}, with no error, although it is
not protobuf. The commit of CAMEL-25329 kept the binary formats out of the
shortcut by not putting it in AbstractJacksonDataFormat, which avroJackson
extends. But protobufJackson extends JacksonDataFormat. The Jackson 3 twin,
camel-jackson3-protobuf, is the same (read from the code).
Checked on 4.24.0-SNAPSHOT with {{camel run}}:
* the body {{\{"id": 1, "name": "Camel"\}}} with {{marshal: protobuf: {library:
Jackson}}}: the same JSON text, with Content-Type application/protobuf;
* the same body with {{marshal: avro: {library: Jackson}}}: "Can not write Avro
output without specifying Schema", as expected.
*Proposed change*: skip the JSON shortcut for the binary Jackson formats, for
example by overriding it in JacksonProtobufDataFormat or by keying it on the
JSON factory, in both camel-jackson-protobuf and camel-jackson3-protobuf.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)