Skip to content

Commit

Permalink
Ensure the XMLStreamWriter is closed after use
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Stein <sormuras@gmail.com>
(cherry picked from commit 6a4cb06)
  • Loading branch information
marcphilipp committed Dec 11, 2024
1 parent 6376f0a commit b20c4e2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ private boolean shouldInclude(TestPlan testPlan, TestIdentifier testIdentifier)
private void writeXmlReport(TestIdentifier testIdentifier, Map<TestIdentifier, AggregatedTestResult> tests,
Writer out) throws XMLStreamException {

new XmlReport(out).write(testIdentifier, tests);
try (XmlReport report = new XmlReport(out)) {
report.write(testIdentifier, tests);
}
}

class XmlReport implements AutoCloseable {
private class XmlReport implements AutoCloseable {

private final XMLStreamWriter xml;
private final ReplacingWriter out;
Expand Down

0 comments on commit b20c4e2

Please sign in to comment.