oscerd opened a new pull request, #29079: URL: https://github.com/apache/camel/pull/29079
Fixes [CAMEL-26238](https://issues.apache.org/jira/browse/CAMEL-26238), found while adding the catalog body types (CAMEL-24961). ## 1. PUTALL with a body that is not a Map **Was:** the `validate` step of `PUTALL` was empty, and `execute` called `cache.putAll(exchange.getIn().getBody(Map.class))`. A body that is not a `Map`, or no body, gave `putAll(null)`, which failed in the cache provider with a bare `NullPointerException` ("map is null" on Hazelcast). **Now:** `PUTALL` validates that the body is a `Map` before it touches the cache, and otherwise fails with an `InvalidPayloadException`: "No body available of type: java.util.Map but has type: java.lang.String on: Message[...] (action PUTALL needs a Map of the keys and values to put in the message body)". The message names the type of the body, never its content. A `Map` body is put as before. ## Tests `JCacheProducerPutTest.testPutAllWithBodyThatIsNotAMapFails` sends a text body and no body with `PUTALL` and checks the `InvalidPayloadException`, its expected type and its message, and that the message does not hold the body. Without the fix in `JCacheProducer` it fails (1 of 1), on the `NullPointerException` that `putAll(null)` throws. Module: 101 tests, 0 failures, 0 errors. ## Docs and generated files The jcache component doc says that `PUTALL` takes a `Map` of the keys and values in the body and fails with any other body; its catalog copy is updated. The `@BodyTypes` of the endpoint already said that a body that is not a `Map` fails `PUTALL`, so the component JSON does not change. ## Not changed - No upgrade guide entry: such a body failed before and fails now, only with a clear exception (`InvalidPayloadException` instead of `NullPointerException`). - `PUT`, `PUTIFABSENT`, `GETANDPUT`, `GETANDREPLACE` and `REPLACE` with no body still fail in the cache provider, which does not accept a null value; the issue does not cover them. Main only, as the other fixes of the CAMEL-24961 follow-ups. _Claude Code on behalf of Andrea Cosentino (oscerd)_ 🤖 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]
