Log4j 2
  1. Log4j 2
  2. LOG4J2-217

PluginManager does not close streams if exceptions occur during plugin init

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta4
    • Fix Version/s: 2.0-beta6
    • Component/s: Core
    • Labels:
      None

      Description

      If an exception occurs during plugin initialization,
      the currently open Log4j2Plugins.dat file is not closed, because
      the call to inputstream.close is not in a finally block.

      o.a.l.l.c.c.p.PluginManager#decode(ClassLoader) line 234

      This may cause the issue reported by Fabian in the log4j-user mailing list:

      From: Fabien Sanglard <fsanglard <at> timeplay.com>
      Subject: Issue with Tomcat auto-redeploy on Windows.
      Newsgroups: gmane.comp.jakarta.log4j.user
      Date: 2013-04-17 20:28:37 GMT (4 days, 13 hours and 8 minutes ago)

      It seems there is an issue with log4j 2 not closing the core JAR handle on Windows.
      It prevents Tomcat from auto redeploying an app.

      Upon updating an hypothetical DiscoveryService.war in the 'webapps' folder, the redeploy will fail:

      SEVERE: [C:\Program Files\apache-tomcat-7.0.39\webapps\DiscoveryService\WEB-INF\lib] could
      not be completely deleted. The presence of the remaining files may cause problems

      Upon inspection it looks like:
      C:\Program Files\apache-tomcat-7.0.39\webapps\DiscoveryService\WEB-INF\lib\log4j-core-2.0-beta4.jar

      Cannot be deleted :/ ! Is there anything special to do so log4j 2 close the JAR handle ?

      Fab

        Activity

        Remko Popma created issue -
        Hide
        Remko Popma added a comment -

        Attached file LOG4J2-217-close-finally.patch fixes this issue by putting in/outputstream.close() calls in finally blocks.

        Show
        Remko Popma added a comment - Attached file LOG4J2-217 -close-finally.patch fixes this issue by putting in/outputstream.close() calls in finally blocks.
        Remko Popma made changes -
        Field Original Value New Value
        Attachment LOG4J2-217-close-finally.patch [ 12579831 ]
        Hide
        Remko Popma added a comment -

        Fixed in revision 1476286.

        Show
        Remko Popma added a comment - Fixed in revision 1476286.
        Remko Popma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0-beta6 [ 12324340 ]
        Resolution Fixed [ 1 ]
        Hide
        Remko Popma added a comment -

        Verified that all existing JUnit tests still work. Closing this issue.

        Show
        Remko Popma added a comment - Verified that all existing JUnit tests still work. Closing this issue.
        Remko Popma made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Remko Popma
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development