bluedenim / log4j-s3-search

Log4j appender with S3, Azure, Google Cloud, and search publishing
MIT License
65 stars 44 forks source link

Prevent thread and object leak #149

Closed jdpgrailsdev closed 5 months ago

jdpgrailsdev commented 5 months ago

@bluedenim We discovered two more leaks when using the appender with a router:

  1. The number of registered shutdown hooks grows unbounded as new appender instances are created
  2. The queue of LoggingEventCache instances grows unbounded as new appender instances are created

This PR attempts to fix both by:

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 commented 5 months ago

This is now in release 5.2.2. Thanks for contributing!