-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
StringMatchFilter would return NPE if configured programmatically with 'null' text. #3153
Copy link
Copy link
Closed
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codeconfigurationAffects the configuration system in a general wayAffects the configuration system in a general waygood first issueIssues that are good for contributors looking to get startedIssues that are good for contributors looking to get startedjavaPull requests that update Java codePull requests that update Java codewaiting-for-maintainer
Metadata
Metadata
Assignees
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codeconfigurationAffects the configuration system in a general wayAffects the configuration system in a general waygood first issueIssues that are good for contributors looking to get startedIssues that are good for contributors looking to get startedjavaPull requests that update Java codePull requests that update Java codewaiting-for-maintainer
Type
Fields
Give feedbackNo fields configured for issues without a type.
StringMatchFilter (Log4j 2.24.1)
When parsing from XML I think if the "text" attribute is missing it will be populated with an empty string due to the Builder field:
However, if for whatever reason, someone was programmatically creating this StringMatchFilter and passed null to "Builder#setMatchString", no validation is performed in the "build()" method or the constructor.
This would lead to a deferred NPE in the
StringMatchFilter#filtermethod:Since String#contains(s) assumes
sis NotNull.I thiink standard behaviour would be to log an error and return null in the 'build()' method if the 'text' field is null.
Also there seems to be a copy/paste error in the
StringMatchFilter.Builder#setMarkerTextjavadoc: