apache / apache/logging-log4j2
RegexReplacement static factory method doesn't handle null 'replacement' attribute correctly
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.7k
- Avg merge
- 21h 30m
- Merged PRs (30d)
- 27
Description
RegexReplacement#createRegexReplacement
Static builder method returns `null`if the `regex`attribute is null, but although it logs an error it does not return `null` if the `replacement` attribute is `null`.
```
public static RegexReplacement createRegexReplacement(
@PluginAttribute("regex") final Pattern regex, @PluginAttribute("replacement") final String replacement) {
if (regex == null) {
LOGGER.error("A regular expression is required for replacement");
return null;
}
if (replacement == null) {
LOGGER.error("A replacement string is required to perform replacement");
}
// FIXME: should we use Matcher.quoteReplacement() here?
return new RegexReplacement(regex, replacement);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.