[ 
https://issues.apache.org/jira/browse/CAMEL-13373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16803851#comment-16803851
 ] 

Alexandru commented on CAMEL-13373:
-----------------------------------

Hello I updated the PR.

I think that theres no quickfix as I had to add woodstox library. This is 
brocken the Checkstyle of the project..

For more details on the pb:

These 2 lines opens the FilesInputStreams that are never closed:

*_InputSource is = exchange.getIn().getMandatoryBody(InputSource.class);_*
*_XMLStreamReader stream = 
exchange.getIn().getMandatoryBody(XMLStreamReader.class);_*

> 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
>            Priority: Major
>
> 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)

Reply via email to