davsclaus opened a new pull request, #29004: URL: https://github.com/apache/camel/pull/29004
Fixes [CAMEL-26178](https://issues.apache.org/jira/browse/CAMEL-26178). ### 1. The producer sent an empty payload for a body it cannot convert **Was:** `CoAPProducer.process` read the POST and PUT payload with `getBody(byte[].class)`. A `Map`, a POJO or a number has no `byte[]` converter, so this was `null` and Californium sent the request with an empty payload. No error; the data was lost. **Now:** the payload is read with `getMandatoryBody(byte[].class)`, so such a body fails the exchange with an `InvalidPayloadException` and nothing is sent. A message without a body still sends an empty payload (same as the `hivemq` producer). ### 2. The consumer answered an unconvertible reply body with 2.05 and an empty payload **Was:** `CamelCoapResource.handleRequest` responded with `target.getBody(byte[].class)`. A `Map`, POJO or number reply body gave `null`, so the client got `2.05 Content` with an empty payload. The component page says such a body gives `5.00 Internal Server Error`. **Now:** a non-null reply body is read with `getMandatoryBody(byte[].class)`, so the existing catch answers `5.00` (with the exception's message only when `muteException=false`, as before). A route without a reply body still answers `2.05` with an empty payload. ### Tests New `CoAPUnconvertibleBodyTest` with an embedded Californium server (no external service): - POST of a `Map` and PUT of a POJO fail with `InvalidPayloadException`, and the server route gets nothing. - a POST without body still sends an empty payload. - a `Map` and a POJO reply body answer `5.00`; a null reply body answers `2.05` with an empty payload. The four tests for the bugs failed before the fix (2.05 instead of 5.00; no exception). Module suite: 92 tests, all pass, with `-Psourcecheck`. ### Docs and generated files - `@BodyTypes` of the endpoint (consumer reply and producer in) no longer says such a body is sent as an empty payload; the four `coap*.json` files are regenerated and copied to the catalog. - The component page describes the producer payload and the consumer `5.00`; the catalog copy is updated. - Upgrade guide 4.24: new `camel-coap` entry, since a route that sent such a body without an error now fails. _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]
