davsclaus commented on code in PR #28904:
URL: https://github.com/apache/camel/pull/28904#discussion_r4444600272
##########
components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXProcessor.java:
##########
@@ -76,6 +89,8 @@ public void process(Exchange exchange) throws Exception {
validatingStreamReader.closeCompletely();
}
}
+ // closing the reader does not close the stream we opened (such as
on a Path)
+ IOHelper.close(is);
Review Comment:
Good catch, thanks. Done in 6e7e98c7f26e: the reader is closed in an inner
`try`, and `IOHelper.close(is)` runs in its `finally`, so the stream of a
`Path` body is closed also when closing the reader throws.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
##########
components/camel-stax/src/main/java/org/apache/camel/component/stax/StAXProcessor.java:
##########
@@ -49,8 +54,16 @@ public StAXProcessor(ContentHandler contentHandler) {
@Override
public void process(Exchange exchange) throws Exception {
XMLStreamReader stream = null;
+ InputStream is = null;
try {
- stream = exchange.getIn().getMandatoryBody(XMLStreamReader.class);
+ Message in = exchange.getIn();
+ stream = in.getBody(XMLStreamReader.class);
Review Comment:
Thanks. `getBody(XMLStreamReader.class)` does not swallow a failing
converter: `convertTo` (not `tryConvertTo`) wraps the error in a
`TypeConversionException` and throws it, so the null branch is only reached
when no converter exists (`byte[]`, `Path`, DOM `Document`). I added this to
the comment in 6e7e98c7f26e.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
--
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]