You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Volkan Yazici (Jira)" <ji...@apache.org> on 2020/11/12 22:16:00 UTC

[jira] [Closed] (LOG4J2-2916) If loggercontext got reconfigured and kafka appender got recreated, the previous producer can not be closed, which cause thread leak

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

Volkan Yazici closed LOG4J2-2916.
---------------------------------
    Resolution: Fixed

> If loggercontext got reconfigured and kafka appender got recreated, the previous producer can not be closed, which cause thread leak
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2916
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2916
>             Project: Log4j 2
>          Issue Type: Bug
>            Reporter: wuqian
>            Assignee: Volkan Yazici
>            Priority: Major
>
> If loggercontext got reconfigured and kafka appender got recreated, the previous kafka producer thread can not be closed, which cause thread leak
>  
> Repeat steps:
> xml configured to use kafka appender
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
> LoggerContext.getContext(false).reconfigure();
>  
> Resolution:
> In case the abstractlogmanager always cache the latest new producer and old producer can not be released.
> When creating new kafkamanager, add a logic to release previous kafka producer.
>  
> public void startup() {
>  // If loggercontext reconfigured and kafka appender got recreated, the previous producer can not be closed
>  // which cause thread leak
>  if(producer != null){
>  producer.close();
>  }
>  producer = producerFactory.newKafkaProducer(config);
> }
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)