jhl221123 opened a new pull request, #3681: URL: https://github.com/apache/logging-log4j2/pull/3681
This pull request addresses issue #3430 by implementing a mechanism to expunge stale entries in `InternalLoggerRegistry`. It builds upon PR #3474 and incorporates feedback from @vy and @ppkarwasz. Key changes include: * **Enabled stale entry detection via `ReferenceQueue`**: When a `Logger` is GC'd, its `WeakReference` is enqueued. Subsequent calls to methods like `getLogger()` or `computeIfAbsent()` trigger `expungeStaleEntries()` to process it. * **Implemented `expungeStaleEntries` logic**: If the `ReferenceQueue` is not empty, a write lock is acquired, the queue is drained, and map entries are scanned once to remove `WeakReferences` with null referents and clean up any empty maps. No action or locking occurs if the queue is initially empty. * **Added unit tests**: Verified the expunging mechanism under various conditions, including GC scenarios and concurrent access. @vy, `ReferenceQueue` has no `peek()`/`isEmpty()`, so I couldn’t do a proper double-check and used an initial `poll()` instead. Feedback is welcome if there's a better way or if I missed something. Thanks! Fixes #3430 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org