logging-log4j2 icon indicating copy to clipboard operation
logging-log4j2 copied to clipboard

Expunge stale loggers in InternalLoggerRegistry on method invocation

Open Suvrat1629 opened this issue 10 months ago • 2 comments

This PR updates InternalLoggerRegistry to automatically remove stale loggers when its methods are invoked. Changes Introduced: Introduced a ReferenceQueue<Logger> to track loggers that have been reclaimed by the garbage collector. Implemented expungeStaleEntries(), which removes stale loggers before executing registry operations. Updated methods like getLogger() and computeIfAbsent() to invoke expungeStaleEntries() before proceeding. Added tests to verify stale loggers are expunged without relying on private methods.

Fixes #3430

Suvrat1629 avatar Feb 19 '25 14:02 Suvrat1629

@vy I have always had a hard time with test cases, I have opened a pr regardless please take look and provide further insights on how i can improve it.

Suvrat1629 avatar Feb 19 '25 15:02 Suvrat1629

Ok sorry about that, I have put back all the comment blocks as they were.

Suvrat1629 avatar Feb 21 '25 14:02 Suvrat1629