[
https://issues.apache.org/jira/browse/CAMEL-26178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-26178.
---------------------------------
Resolution: Fixed
Fixed by https://github.com/apache/camel/pull/29004 (merged to main as
7b14a24bcb4b45aad92d51832b8467a880e760eb).
_Claude Code on behalf of Claus Ibsen (davsclaus)_
> camel-coap - a POST/PUT body that cannot be converted to byte[] is sent as an
> empty payload, and the consumer answers such a reply body with an empty 2.05
> ----------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26178
> URL: https://issues.apache.org/jira/browse/CAMEL-26178
> Project: Camel
> Issue Type: Bug
> Components: camel-coap
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> Found while adding the catalog body types of coap, coaps, coap+tcp and
> coaps+tcp (CAMEL-24961, PR #28411).
> h4. 1. The producer sends an empty payload for a body it cannot convert
> {{CoAPProducer.process}} (main 2a465aa4814c, lines 73 and 77) reads the POST
> and PUT payload with {{exchange.getIn().getBody(byte[].class)}}. For a body
> that has no {{byte[]}} converter (a Map, a POJO, an Integer 42) this is null,
> and Californium sends the request with an empty payload. There is no error,
> so the message is lost without notice. Checked on 4.24.0-SNAPSHOT with an
> embedded Californium UDP and TCP server.
> Proposed: read the payload with {{getMandatoryBody(byte[].class)}} so such a
> body fails the exchange.
> h4. 2. The consumer answers an unconvertible reply body with 2.05 and an
> empty payload
> {{CamelCoapResource.handleRequest}} (main 2a465aa4814c, line 168) responds
> with {{target.getBody(byte[].class)}}. A Map, POJO or Integer reply body
> gives null, so the client gets {{2.05 Content}} with an empty payload; a List
> gives {{5.00}}. The coap doc ("Error responses from the CoAP consumer") says
> a body that cannot be converted to the response payload gives {{5.00 Internal
> Server Error}}. Checked on 4.24.0-SNAPSHOT with an embedded Californium
> server.
> Proposed: use {{getMandatoryBody(byte[].class)}} for a non-null reply body,
> so the existing catch answers {{5.00}} as documented.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)