[main] Port `InternalLoggerRegistry` from `2.x` (#3418 and #3681 ports) (#4157)
* Port `InternalLoggerRegistry` from `2.x`
Minimizes lock usage by moving logger instantiation outside the write lock (PR #3418). Adds stale entry detection via ReferenceQueue (PR #3681).
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
* Apply spotless formatting to InternalLoggerRegistryTest
* Fix InternalLoggerRegistry null-MessageFactory lookup mismatch in Log4j 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.
* InternalLoggerRegistry: add Javadoc, align with 2.x naming, fix return-in-finally, add expungeStaleEntries
---------
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
3 files changed