You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "sharanggupta (via GitHub)" <gi...@apache.org> on 2026/10/23 15:25:58 UTC

[PR] Respect putIfAbsent results and null arguments in AbstractConfiguration logger mutators [logging-log4j2]

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

   Fixes #3155.
   
   `AbstractConfiguration.addLoggerAppender`, `addLoggerFilter` and `setLoggerAdditive` (the implementation behind `core.Logger#addAppender`, `#addFilter` and `#setAdditive`) ignored the result of their `putIfAbsent` calls:
   
   - `addLoggerAppender`: when a *different* appender instance was already registered under the same name, the new instance was not registered but was still attached to the `LoggerConfig`, so the logger wrote to an appender the configuration never started or stopped while `getAppender(name)` returned another one. The registered instance is now attached instead (first wins, as `addAppender` already behaves), with a status-logger warning.
   - All three: the result of `loggerConfigs.putIfAbsent(loggerName, nlc)` is respected; when a config already exists the change is applied to it instead of re-wiring the parents and updating the loggers again. Under the method lock and the exact-name lookup that precedes it this branch is defensive, so it has no test of its own.
   - `addLoggerFilter` and `setLoggerAdditive` now ignore `null` arguments like `addLoggerAppender` does, instead of throwing `NullPointerException` (side note 1 in the issue).
   
   Tests, one per method in `AbstractConfigurationTest`: the duplicate-name appender case; the filter case (null arguments ignored, exactly one `LoggerConfig` created with the right parent, both filters applied); the additive case (null logger ignored, one config created, additivity reflected by the logger). All three fail before the change and pass after. Changelog entry for 2.x included.
   
   ## Checklist
   
   * Based on `2.x`
   * `./mvnw verify` on `log4j-core` / `log4j-core-test` with `AbstractConfigurationTest` succeeds (spotless applied)
   * Changelog entry in `src/changelog/.2.x.x`
   * Tests are provided
   


-- 
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-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Respect putIfAbsent results and null arguments in AbstractConfiguration logger mutators [logging-log4j2]

Posted by "sharanggupta (via GitHub)" <gi...@apache.org>.
sharanggupta commented on PR #4423:
URL: https://github.com/apache/logging-log4j2/pull/4423#issuecomment-6396909031

   Folded into #4419 as a second commit (941a6a78ab), as asked on #3155. Closing this one.
   


-- 
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-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Respect putIfAbsent results and null arguments in AbstractConfiguration logger mutators [logging-log4j2]

Posted by "sharanggupta (via GitHub)" <gi...@apache.org>.
sharanggupta closed pull request #4423: Respect putIfAbsent results and null arguments in AbstractConfiguration logger mutators
URL: https://github.com/apache/logging-log4j2/pull/4423


-- 
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-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org