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

   ## Summary
   
   Completes the port of #2962 by removing the now-dead `checkMessageFactory` 
machinery from `LoggerContext`.
   The MessageFactory-namespaced `InternalLoggerRegistry` itself was already 
ported in #4157. This PR removes the leftover core code that only existed to 
warn about message-factory mismatches under the old name-keyed registry.
   
   ## Why `checkMessageFactory` was dead code
   
   The `LoggerRegistry` now keys loggers by **(name, message factory)**. As a 
result:
   
   - `computeIfAbsent(name, mf, newLogger)` always returns a logger whose 
message factory matches the requested one, so the warning branch 
`!loggerMessageFactory.equals(messageFactory)` could never fire.
   - `getLogger` normalizes a `null` message factory to the default *before* 
reaching the registry, so the null-mismatch branch was unreachable as well.
   
   The behavior this method guarded against — returning an existing logger 
created with a *different* message factory — no longer exists: a request with a 
different factory now returns a distinct, correctly-bound logger instead of the 
old logger plus a warning. `2.x` removed this dead method in PR #2936, the same 
change that introduced the namespaced registry there; this PR mirrors that 
change in the `3.x`, keeping it a faithful port.
   
   **Note on registry placement:** as suggested in 
https://github.com/apache/logging-log4j2/issues/2962#issuecomment-2469688771, 
the namespaced registry was kept out of `log4j-api`; it lives in `log4j-core` 
(mirroring `2.x`) rather than `log4j-kit`, since kit sits below core and can't 
reference the core `Logger` type.
   
   ## Changes
   
   1. **`log4j-core` — `LoggerContext`**
      - Removed private `checkMessageFactory(ExtendedLogger, MessageFactory)` 
and its call site in `getLogger(String, MessageFactory)`.
      - Removed the now-unused `ExtendedLogger` and `StatusLogger` imports.
      - Added `@Nullable` to the message-factory parameter of 
`getLogger(String, MessageFactory)` and `hasLogger(String, MessageFactory)`; 
refreshed the `getLogger` Javadoc to describe the message-factory-matching 
semantics.
   2. **`log4j-core-test` — `LoggerTest`**
      - Added regression test 
`getLogger_String_MessageFactoryMismatchProducesNoWarning`: re-requests a 
logger with a different and with a `null` message factory, and asserts no 
"created with the message factory" status warning is emitted.
      - Kept the `builder` hardcoded source-line constant in sync with the file 
layout.


-- 
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