Claus Ibsen created CAMEL-26175:
-----------------------------------
Summary: camel-odata - a byte array body for CREATE/UPDATE is sent
as a JSON array of numbers, and stream or File bodies fail
Key: CAMEL-26175
URL: https://issues.apache.org/jira/browse/CAMEL-26175
Project: Camel
Issue Type: Bug
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while adding the catalog body types of odata (new in 4.23) (CAMEL-24961,
PR #28412).
h4. 1. A byte array body for CREATE and UPDATE is sent as a JSON array of
numbers
{{ODataProducer}} (main 2a465aa4814c, lines 154 and 159) sends
{{ODataHelper.toJson(body)}}, which passes anything that is not a String to
{{Jsoner.serialize}} ({{ODataHelper}} line 38), so a {{byte[]}} with JSON text
is sent as {{[123,34,...]}}. Checked on 4.24.0-SNAPSHOT with WireMock.
Proposed: convert byte array, stream and file bodies to text and send them as
is (see 2).
h4. 2. An InputStream or File body fails instead of being sent as JSON text
The same {{Jsoner.serialize}} call fails for an {{InputStream}} or a
{{java.io.File}} with JSON content. Checked on 4.24.0-SNAPSHOT with WireMock.
Proposed: read stream and file bodies as JSON text, as for a String.
h4. 3. A null body sends an empty POST or PATCH
{{ODataHelper.toJson}} (main 2a465aa4814c, line 29) returns null for a null
body, and CREATE or UPDATE then sends a request with no content, with no error.
Checked on 4.24.0-SNAPSHOT with WireMock.
Proposed: fail with a clear message when CREATE or UPDATE has no body.
h4. 4. A JSON response that is not an object fails
{{ODataHelper.parseJsonObject}} (main 2a465aa4814c, lines 47-49) throws
"Expected an OData JSON object response" when the answer is a JSON array or a
plain value, so such a response cannot be read. Checked on 4.24.0-SNAPSHOT with
WireMock.
Proposed: return the parsed value (array or plain value) as the body instead of
failing.
h4. 5. The catalog shows no default for the operation option
{{ODataConfiguration.operation}} (main 2a465aa4814c, lines 26-27) is
initialized to {{READ_SET}}, but its {{@UriParam}} has no {{defaultValue}}, so
the catalog and the doc show no default. Read in the code, not run.
Proposed: add {{defaultValue = "READ_SET"}} and regenerate the catalog.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)