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 2023/03/08 00:15:06 UTC

[GitHub] [maven] elharo commented on a diff in pull request #1043: Fix callee closing streams and readers instead of callers

elharo commented on code in PR #1043:
URL: https://github.com/apache/maven/pull/1043#discussion_r1128780743


##########
maven-xml-impl/src/main/java/org/apache/maven/internal/xml/XmlNodeBuilder.java:
##########
@@ -84,14 +81,9 @@ public static XmlNodeImpl build(Reader reader, boolean trim) throws XmlPullParse
      */
     public static XmlNodeImpl build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
             throws XmlPullParserException, IOException {
-        try (Reader closeMe = reader) {
-            final XmlPullParser parser = new MXParser();
-            parser.setInput(reader);
-
-            final XmlNodeImpl node = build(parser, trim, locationBuilder);
-
-            return node;
-        }
+        XmlPullParser parser = new MXParser();

Review Comment:
   since this is a public method this is a potentially behavior breaking change, and could affect code outside this repo.
   
   I'm also not certain this is a good idea. An XML parser is going to process the entire stream. They're won't be anything left to read from, and closing twice isn't usually a problem whereas forgetting to close a file can be.



-- 
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