Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13373

camel-stax - FileInputStream not closed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.23.1
    • 3.0.0.M4, 3.0.0
    • camel-stax
    • None
    • Unknown

    Description

      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(); }

      *

      }

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            Sirbu Alexandru
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: