Skip to content

Commit

Permalink
Merge pull request #183 from hazendaz/main
Browse files Browse the repository at this point in the history
[cleanup] Use try with resources to ensure reader is closed
  • Loading branch information
hazendaz authored Apr 6, 2024
2 parents 72b6ee4 + f64a309 commit f00445d
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ public String format(String documentText) {
validateWellFormedness(documentText);
}

Reader reader = new StringReader(documentText);
FormatState state = new FormatState();

try {
try (Reader reader = new StringReader(documentText)) {
while (true) {
reader.mark(1);
int intChar = reader.read();
Expand All @@ -111,7 +110,6 @@ public String format(String documentText) {
}
copyNode(reader, state);
}
reader.close();
} catch (IOException e) {
logger.error("{}", e.getMessage());
logger.debug("", e);
Expand Down

0 comments on commit f00445d

Please sign in to comment.