You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2019/06/18 08:15:00 UTC
[jira] [Resolved] (CAMEL-13373) camel-stax - FileInputStream not
closed
[ https://issues.apache.org/jira/browse/CAMEL-13373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-13373.
---------------------------------
Resolution: Fixed
Assignee: Claus Ibsen
Fix Version/s: 3.0.0.M4
3.0.0
Thanks for reporting and the PR.
Mind that this happens on windows only
> camel-stax - FileInputStream not closed
> ---------------------------------------
>
> Key: CAMEL-13373
> URL: https://issues.apache.org/jira/browse/CAMEL-13373
> Project: Camel
> Issue Type: Bug
> Components: camel-stax
> Affects Versions: 2.23.1
> Reporter: Alexandru
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 3.0.0, 3.0.0.M4
>
>
> The StAXProcessor.java class does not close the stream it opens.
> I had to modify it like this:
> public void process(Exchange exchange) throws Exception {
> InputSource is = exchange.getIn().getMandatoryBody(InputSource.class);
> XMLStreamReader stream = exchange.getIn().getMandatoryBody(XMLStreamReader.class);
> // Fermeture de la inputstream ici, car dans la version originale de la classe la stream reste ouverte.
> *try(InputStream inputStreamToClose = is.getByteStream()) {*
> XMLReader reader = new StaxStreamXMLReader(stream);
> ContentHandler handler;
> if (this.contentHandlerClass != null)
> { handler = (ContentHandler) this.contentHandlerClass.newInstance(); }
> else
> { handler = this.contentHandler; }
> reader.setContentHandler(handler);
> reader.parse(is);
> if (ExchangeHelper.isOutCapable(exchange))
> { exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(handler); }
> else
> { exchange.getIn().setBody(handler); }
> } *finally*
> *{ // Fermeture de la strem ValidatingStreamReader validatingStreamReader = (ValidatingStreamReader)stream; validatingStreamReader.closeCompletely(); }*
> *}*
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)