@bluedenim We discovered two more leaks when using the appender with a router:
The number of registered shutdown hooks grows unbounded as new appender instances are created
The queue of LoggingEventCache instances grows unbounded as new appender instances are created
This PR attempts to fix both by:
De-registering the shutdown hook thread when the stop() method is called by Log4j
Removing the cache from the queue when the stop() method on the LoggingEventCache is called as part of the appender stop flow implemented previously.
I do wonder if the shutdown hook is even necessary at this point, even in the standard single appender creation flow. Might be worth doing some testing to see if the stop() implementation makes the shutdown hook unnecessary, though it may still be a good safety net when an application crashes and Log4j cannot complete its shutdown flow.
@bluedenim We discovered two more leaks when using the appender with a router:
LoggingEventCache
instances grows unbounded as new appender instances are createdThis PR attempts to fix both by:
stop()
method is called by Log4jstop()
method on theLoggingEventCache
is called as part of the appender stop flow implemented previously.I do wonder if the shutdown hook is even necessary at this point, even in the standard single appender creation flow. Might be worth doing some testing to see if the
stop()
implementation makes the shutdown hook unnecessary, though it may still be a good safety net when an application crashes and Log4j cannot complete its shutdown flow.