[main] Port InternalLoggerRegistry from 2.x (#3418 and #3681 ports)#4157
Open
vpelikh wants to merge 3 commits into
Open
[main] Port InternalLoggerRegistry from 2.x (#3418 and #3681 ports)#4157vpelikh wants to merge 3 commits into
InternalLoggerRegistry from 2.x (#3418 and #3681 ports)#4157vpelikh wants to merge 3 commits into
Conversation
InternalLoggerRegistry from 2.xInternalLoggerRegistry from 2.x (#3418 and #3681 port)
InternalLoggerRegistry from 2.x (#3418 and #3681 port)InternalLoggerRegistry from 2.x (#3418 and #3681)
27 tasks
Minimizes lock usage by moving logger instantiation outside the write lock (PR apache#3418). Adds stale entry detection via ReferenceQueue (PR apache#3681). Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
vpelikh
force-pushed
the
issue/3418-internal-logger-registry
branch
from
July 16, 2026 07:23
d4ae379 to
4d7dd8e
Compare
InternalLoggerRegistry from 2.x (#3418 and #3681)InternalLoggerRegistry from 2.x (#3418 and #3681 ports)
…4j 3 InternalLoggerRegistry.getLogger(name, null) normalized null to a hardcoded ParameterizedMessageFactory.INSTANCE, but LoggerContext stored loggers under its DI-injected defaultMessageFactory (ReusableMessageFactory in Log4j 3). This store-key/get-key mismatch caused testGetLoggerRetrievesExistingLogger, testHasLoggerReturnsCorrectStatus, and testExpungeStaleWeakReferenceEntries to all fail. - InternalLoggerRegistry: constructor-inject defaultMessageFactory (final field), resolve null→defaultMessageFactory instead of hardcoded INSTANCE. - LoggerContext: construct InternalLoggerRegistry with its own defaultMessageFactory after DI resolution. - Test: iterate all message-factory buckets (.values()) instead of assuming ParameterizedMessageFactory.INSTANCE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port
InternalLoggerRegistryfrom2.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 aLoggeris garbage collected, itsWeakReferenceis enqueued. Subsequent calls togetLogger(),computeIfAbsent(), orhasLogger()trigger expunging of stale entries, preventing memory leaks from accumulated dead entries (PR #3681).Changes:
InternalLoggerRegistry— new multi-levelWeakHashMap<MessageFactory, HashMap<String, WeakReference<Logger>>>structure withReadWriteLockLoggerContext.getLogger()— simplified to useregistry.computeIfAbsent()(movesnewLogger()outside the write lock)InternalLoggerRegistryTest— 6 tests covering creation, lookup, and stale entry expunging (WeakReference + MessageFactory GC scenarios)