Closed
Description
In RegexFilter.Builder (2.24.1) the PluginAttribute for useRawMsg
is a Boolean
default null
.
@PluginFactory
public static RegexFilter createFilter(
// @formatter:off
@PluginAttribute("regex") final String regex,
@PluginElement("PatternFlags") final String[] patternFlags,
@PluginAttribute("useRawMsg") final Boolean useRawMsg,
@PluginAttribute("onMatch") final Result match,
@PluginAttribute("onMismatch") final Result mismatch)
// @formatter:on
throws IllegalArgumentException, IllegalAccessException {
if (regex == null) {
LOGGER.error("A regular expression must be provided for RegexFilter");
return null;
}
return new RegexFilter(useRawMsg, Pattern.compile(regex, toPatternFlags(patternFlags)), match, mismatch);
}
The RegexFilter
constructor expects a boolean primitive.
private RegexFilter(final boolean raw, final Pattern pattern, final Result onMatch, final Result onMismatch) {
super(onMatch, onMismatch);
this.pattern = pattern;
this.useRawMessage = raw;
}
I believe, if the useRawMsg
attribute is not set (undefined/null), auto-boxing from Boolean
to boolean
will cause/throw a NPE which is not caught and the builder will not return null
as it should?
Also, the 'regex' attribute should probably be defined as @required for the isValid()
builder-functionality to work correctly.
Metadata
Metadata
Assignees
Labels
No labels