Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-938

org.apache.logging.log4j.core.jmx.Server never shuts down the ExecutorService it creates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.1
    • 2.2
    • JMX
    • None

    Description

      The class org.apache.logging.log4j.core.jmx.Server creates an ExecutorService at construction time and and stores it as an instance variable of type Executor (named executor).

      This executor service is never shut down (I guess the unregisterMBeans() methods may be good candidates, with some care for unregisterMBeans(MBeanServer) which performs unregistration only for a single MBeanServer). This causes a memory leak if Log4j is used in a web application (under Tomcat, for instance) and the JMX services have been used (i.e.: the Server class has been instantiated).

      But even worse, what I'm observing is that a notification Job may be submitted to that executor by javax.management.NotificationBroadcasterSupport.sendNotification(Notification), invoked by org.apache.logging.log4j.core.jmx.StatusLoggerAdmin.log(StatusData) in certain circumstances exactly during Tomcat shutdown process: since the executor is using non-daemon threads to execute tasks, this eventually prevents the application server to shutdown (I have to kill it).

      Attachments

        1. LOG4J2-938.patch
          10 kB
          Mauro Molinari

        Activity

          People

            rpopma Remko Popma
            mauromol Mauro Molinari
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: