Skip to content

setEscapeString(null) silently ignored, previous state retained #351

Description

@elharo

In src/main/java/org/apache/maven/shared/filtering/AbstractFilterReaderLineEnding.java, lines 67–73:

public void setEscapeString(String escapeString) {
    // TODO NPE if escapeString is null ?
    if (escapeString != null && !escapeString.isEmpty()) {
        this.escapeString = escapeString;
        this.useEscape = true;
        calculateMarkLength();
    }
}

The code's own TODO acknowledges the problem. When escapeString is null:

  • this.escapeString retains its previous value (not cleared)
  • this.useEscape remains true if it was previously set from an earlier non-null call
  • calculateMarkLength() is not called, leaving markLength potentially wrong

A caller who sets escape string to non-null, then later sets it to null to disable escaping, will find escaping still active with the old string. The field should be cleared and useEscape set to false for null/empty input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions