davsclaus opened a new pull request, #28905: URL: https://github.com/apache/camel/pull/28905
Fixes [CAMEL-26129](https://issues.apache.org/jira/browse/CAMEL-26129). ### 1. A null or Map body fails with a NullPointerException `DfdlEndpoint.onExchange` read the body with `getBody(Document.class)` (UNPARSE) and `getBody(byte[].class)` (PARSE). For a null or Map body these return null, and Daffodil failed with a NullPointerException. Change: both directions now use `getMandatoryBody(...)`, so the exchange fails with an `InvalidPayloadException` that names the expected type and the actual body. Tests: `DfdlComponentTest.testParseNullBody`, `testParseMapBody`, `testUnparseNullBody`, `testUnparseMapBody`. All four failed before the fix. ### 2. DfdlParseException and DfdlUnparseException have no message Neither constructor passed a message to `super`, so `getMessage()` was null and a parse error was logged as "null". The diagnostics were only in `getParseResult()` / `getUnparseResult()`. Change: the message is now built from the Daffodil diagnostics, e.g. `DFDL parse failed: <diagnostic>; <diagnostic>` and `DFDL unparse failed: ...`. With no diagnostics, the message is just the prefix. This covers both the endpoint and the data format, which share these exceptions. Tests: the existing `testParseError` and `testUnparseError` in `DfdlComponentTest` and `DfdlDataFormatTest` now also check the message. All four failed before the fix. ### Notes - Module tests: 12 run, 0 failures (`mvn clean install -Psourcecheck` in `components/camel-dfdl`). - No options, headers or docs changed, so nothing to regenerate. The body type description ("A Map or no body fails") stays correct. - No upgrade guide entry: only the exception type for a null/Map body (NPE before) and the exception message (null before) change. - Not changed: `DfdlDataFormat.marshal` sets the unparse exception on the exchange instead of throwing it. That is out of scope for this issue. _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]
