davsclaus opened a new pull request, #29022: URL: https://github.com/apache/camel/pull/29022
Fixes [CAMEL-26199](https://issues.apache.org/jira/browse/CAMEL-26199). ### 1. A non-Map body or no body fails with a bare NullPointerException **What was wrong:** `SpringLdapProducer.process` read the body with the non-mandatory `getBody(Map.class)`. For a String body or no body this gives `null`, and `body.get("dn")` then threw a `NullPointerException` that did not say a Map is expected. **What changed:** the body is read with `getMandatoryBody(Map.class)`, so the exchange fails with an `InvalidPayloadException` that names `java.util.Map` and the actual body type. The body is now read after the "operation must not be empty" check, so an endpoint without an operation still fails with the same `UnsupportedOperationException` as before (the existing `testEmptyExchange` and `testWrongBodyType` rely on that). ### 2. Same method: function_driven without a `function` entry **What was wrong:** a `function_driven` body without a `function` entry also failed with a bare `NullPointerException`. **What changed:** it now fails with an `UnsupportedOperationException` naming the missing `'function'` entry (the same exception type the producer already uses for an empty DN). ### Tests New tests in `SpringLdapProducerTest` (Mockito, no LDAP server): - `testStringBodyNamesTheExpectedMap` and `testNoBodyNamesTheExpectedMap`: expect an `InvalidPayloadException` for `Map`. - `testFunctionDrivenWithoutFunction`: expects the message naming `'function'`. All three failed before the fix (NullPointerException). Module: 19 tests, all pass (`mvn clean install -Psourcecheck`). ### Docs The component doc says another body, or no body, fails with an `InvalidPayloadException`; the copy under `catalog/camel-catalog` is updated. The `@BodyTypes` text ("Another body, such as a JSON text, fails") was already right and is unchanged. No upgrade-guide entry: only the exception type of an already failing exchange changes. ### Not changed A wrong value type in an entry (for example a non-String `dn`) still fails with a `ClassCastException`; that error already names both types. _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]
