Skip to content

Commit f00445d

Browse files
authored
Merge pull request #183 from hazendaz/main
[cleanup] Use try with resources to ensure reader is closed
2 parents 72b6ee4 + f64a309 commit f00445d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/main/java/net/revelc/code/formatter/xml/lib/XmlDocumentFormatter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ public String format(String documentText) {
9797
validateWellFormedness(documentText);
9898
}
9999

100-
Reader reader = new StringReader(documentText);
101100
FormatState state = new FormatState();
102101

103-
try {
102+
try (Reader reader = new StringReader(documentText)) {
104103
while (true) {
105104
reader.mark(1);
106105
int intChar = reader.read();
@@ -111,7 +110,6 @@ public String format(String documentText) {
111110
}
112111
copyNode(reader, state);
113112
}
114-
reader.close();
115113
} catch (IOException e) {
116114
logger.error("{}", e.getMessage());
117115
logger.debug("", e);

0 commit comments

Comments
 (0)