You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/07/01 12:11:46 UTC
[PR] PrettyPrintXMLWriter: handle null lineIndent in constructors [maven-shared-utils]
elharo opened a new pull request, #382:
URL: https://github.com/apache/maven-shared-utils/pull/382
Constructors accepting a `String lineIndent` parameter document it "can be null" but call `lineIndent.toCharArray()` without a null check, throwing `NullPointerException`.
Fixed constructors now fall back to the default indentation (two spaces) when `lineIndent` is null, and to `"\n"` when `lineSeparator` is null — matching the behavior of the constructors that don't take these parameters.
Fixes https://github.com/apache/maven-shared-utils/issues/381
Commits:
- 581ca4a — Add failing test: PrettyPrintXMLWriter with null lineIndent
- b38df77 — PrettyPrintXMLWriter: handle null lineIndent/lineSeparator in constructors
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PrettyPrintXMLWriter: handle null lineIndent in constructors [maven-shared-utils]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #382:
URL: https://github.com/apache/maven-shared-utils/pull/382#discussion_r3505807649
##########
src/test/java/org/apache/maven/shared/utils/xml/PrettyPrintXmlWriterTest.java:
##########
@@ -93,6 +93,13 @@ public void testPrettyPrintXMLWriterWithGivenLineIndenter() throws IOException {
assertEquals(expectedResult(" "), w.toString());
}
+ @Test
+ public void testPrettyPrintXMLWriterWithNullLineIndent() throws IOException {
+ PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter(new StringWriter(), (String) null);
+ writer.startElement("div");
+ writer.endElement();
+ }
Review Comment:
The new test only exercises the constructor without asserting the expected fallback behavior. As written it would pass even if the writer uses the wrong default indentation/formatting, as long as it doesn’t throw. Consider asserting the rendered output matches the default pretty-printed format (and ideally add a similar assertion-based test for the `lineSeparator == null` constructor path).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PrettyPrintXMLWriter: handle null lineIndent in constructors [maven-shared-utils]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo merged PR #382:
URL: https://github.com/apache/maven-shared-utils/pull/382
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org