davsclaus opened a new pull request, #28903:
URL: https://github.com/apache/camel/pull/28903

   Fixes [CAMEL-26127](https://issues.apache.org/jira/browse/CAMEL-26127).
   
   ## A null, Map or DOM Document body fails with a NullPointerException
   
   **What was wrong:** `FopProducer.process` read the body with 
`getBody(StreamSource.class)`. That returns null for no body, a `Map` and a DOM 
`Document` (there is no `Document` to `StreamSource` converter). The null 
`Source` was passed to the transformer, which failed with 
`NullPointerException: Cannot invoke 
"javax.xml.transform.Source.getSystemId()"`. A DOM Document is a valid XSL-FO 
input but was rejected this way.
   
   **What changed:**
   - A body that is already a `javax.xml.transform.Source` is used as is.
   - A DOM `Node` (such as a `Document`) is wrapped in a `DOMSource`.
   - Any other body goes through `getMandatoryBody(StreamSource.class)`, the 
same conversion as before. No body, a `Map`, or anything else that cannot be 
converted now fails with an `InvalidPayloadException`.
   - The `@BodyTypes` input of the endpoint now lists `pojo` and says a DOM 
Document or a `Source` is accepted; the component JSON and the catalog copy are 
regenerated.
   
   **Security:** no new XML parsing is added. A DOM body is already parsed, so 
it is not parsed again. String, bytes, stream and file bodies still go through 
the secure `TransformerFactory` (secure processing, no external DTD or 
stylesheet), and `FopExternalEntityTest` still passes.
   
   **Tests:** new `FopBodyTest`: a DOM Document and a DOMSource render to text; 
no body and a Map body fail with `InvalidPayloadException`. Without the fix, 
the Document, null and Map tests fail with the NullPointerException (the 
DOMSource test already passed via the converter). Module build `mvn clean 
install -Psourcecheck`: 14 tests, 0 failures.
   
   **Not changed:** the producer still writes the result with 
`exchange.getOut()` and a `ByteArrayOutputStream` body; that is unrelated to 
this bug. No docs or upgrade-guide change: bodies that used to work behave the 
same, and the only difference for broken bodies is a clear 
`InvalidPayloadException` instead of a NullPointerException.
   
   _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]

Reply via email to