Skip to content

RegexReplacement static factory method doesn't handle null 'replacement' attribute correctly #3215

@JWT007

Description

@JWT007

RegexReplacement#createRegexReplacement

Static builder method returns nullif the regexattribute 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);
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

To triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions