Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
None
Description
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 = producerFactory.newKafkaProducer(config);
}