vpelikh opened a new pull request, #4157:
URL: https://github.com/apache/logging-log4j2/pull/4157

   Port `InternalLoggerRegistry` from `2.x` (#3418, #3681)
   
   Minimizes lock usage by moving logger instantiation outside the write lock, 
preventing deadlocks that could occur when the logger constructor triggers 
property lookups or other pluggable operations (PR #3418, closes #3399).
   
   Adds stale entry detection and removal via `ReferenceQueue` — when a 
`Logger` is garbage collected, its `WeakReference` is enqueued. Subsequent 
calls to `getLogger()`, `computeIfAbsent()`, or `hasLogger()` trigger expunging 
of stale entries, preventing memory leaks from accumulated dead entries (PR 
#3681).
   
   **Changes:**
   - `InternalLoggerRegistry` — new multi-level `WeakHashMap<MessageFactory, 
HashMap<String, WeakReference<Logger>>>` structure with `ReadWriteLock`
   - `LoggerContext.getLogger()` — simplified to use 
`registry.computeIfAbsent()` (moves `newLogger()` outside the write lock)
   - `InternalLoggerRegistryTest` — 6 tests covering creation, lookup, and 
stale entry expunging (WeakReference + MessageFactory GC scenarios)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to