Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-1012

Possible resource leak in FilePoller

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.1.1
    • 3.1.2, 3.2
    • servicemix-file
    • None
    • Windows XP, JDK 5.0

    Description

      In the org.apache.servicemix.components.file.FilePoller#processFile(File) it is possible that allocated file would leak. Now, it goes like:

      protected void processFile(File aFile) throws Exception

      { String name = aFile.getCanonicalPath(); InputStream in = new BufferedInputStream(new FileInputStream(aFile)); InOnly exchange = getExchangeFactory().createInOnlyExchange(); NormalizedMessage message = exchange.createMessage(); exchange.setInMessage(message); marshaler.readMessage(exchange, message, in, name); getDeliveryChannel().sendSync(exchange); in.close(); }

      But, we should properly clean-up in the case of exception thrown before in.close(). Thus, should be:

      protected void processFile(File aFile) throws Exception {
      InputStream in = null;
      try

      { String name = aFile.getCanonicalPath(); in = new BufferedInputStream(new FileInputStream(aFile)); InOnly exchange = getExchangeFactory().createInOnlyExchange(); NormalizedMessage message = exchange.createMessage(); exchange.setInMessage(message); marshaler.readMessage(exchange, message, in, name); getDeliveryChannel().sendSync(exchange); }


      finally {
      if (in != null)

      { in.close(); }

      }
      }

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            karaznie Artur Karazniewicz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: