Skip to content

PrettyPrintXMLWriter NPE when lineIndent is null #381

Description

@elharo

Constructors accepting a String lineIndent parameter document that it "can be null" (e.g. PrettyPrintXMLWriter(Writer, String)), but then call lineIndent.toCharArray() without a null check, throwing NullPointerException.

Impacted constructors:

  • PrettyPrintXMLWriter(PrintWriter, String) (line 65) → PrettyPrintXMLWriter(PrintWriter, String, String, String) (line 98)
  • PrettyPrintXMLWriter(Writer, String) (line 73)
  • PrettyPrintXMLWriter(Writer, String, String, String) (line 107)
  • PrettyPrintXMLWriter(PrintWriter, String, String, String, String) (line 138)

Also setLineSeparator(String) and setLineIndenter(String) have the same pattern, though their Javadocs don't say null is allowed.

When null is passed, the expected behavior should be to fall back to the default: two spaces for line indent, newline for line separator.

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