fix: null-check parseAppender result in log4j-1.2-api XmlConfiguration#4172
fix: null-check parseAppender result in log4j-1.2-api XmlConfiguration#4172SebTardif wants to merge 2 commits into
Conversation
parseAppender can return null when the appender cannot be instantiated. Dereferencing getName() then caused an NPE during configuration parsing. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
@SebTardif, thanks for the fix. we'll need a unit test reproducing the NPE and changelog also. Also, could you check if the other parsers in this switch statement (parseLogger, etc.) need the exact same null check? Let's fix them all at once. Lastly, let's make sure we log a warning when appender == null so it doesn't fail silently for the user.
|
- Log a warning when parseAppender returns null or getName() is null - Unit test with invalid appender class that NPE'd without the guard - Changelog entry for PR 4172 - Sibling parse() cases (parseCategory/parseRoot) are void and already null-safe; only APPENDER_TAG used a nullable return
Thanks for the review. Addressed in the latest commit:
Spotless clean; local green: |
Summary
In log4j-1.2-api
XmlConfiguration,parseAppender()can return null. The code calledappender.getName()unconditionally, causing an NPE on bad appender configuration.Fix
Skip null appenders after
parseAppender.Testing
Logic-only guard; existing suite in CI.