[ 
https://issues.apache.org/jira/browse/LOG4J2-938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Remko Popma resolved LOG4J2-938.
--------------------------------
       Resolution: Fixed
    Fix Version/s: 2.2
         Assignee: Remko Popma

Fixed in master in commit d329cf3.
Please verify and close.

(The new system property is documented on the Configuration manual page.)

Mauro, I agree this solution is a compromise, but I hope its simplicity will 
help avoid future issues. :-) To answer your question: if 
Log4jServletContextListener is not on the classpath it could be that the user 
simply did not include the log4j-web module, and we may still be running in a 
web container. Also, it looks like the core.lookup.Interpolator class uses a 
similar mechanism (it looks for ServletContext) to see if it should enable the 
{{web:}} lookup or not, so there is some precedent.

Thanks very much for raising the issue and your detailed analysis on the cause!

> org.apache.logging.log4j.core.jmx.Server never shuts down the ExecutorService 
> it creates
> ----------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-938
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-938
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: JMX
>    Affects Versions: 2.1
>            Reporter: Mauro Molinari
>            Assignee: Remko Popma
>            Priority: Critical
>             Fix For: 2.2
>
>         Attachments: LOG4J2-938.patch
>
>
> 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).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to