Skip to content

Commit b20c4e2

Browse files
committedDec 11, 2024
Ensure the XMLStreamWriter is closed after use
Co-authored-by: Christian Stein <[email protected]> (cherry picked from commit 6a4cb06)
1 parent 6376f0a commit b20c4e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎junit-platform-reporting/src/main/java/org/junit/platform/reporting/legacy/xml/XmlReportWriter.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ private boolean shouldInclude(TestPlan testPlan, TestIdentifier testIdentifier)
115115
private void writeXmlReport(TestIdentifier testIdentifier, Map<TestIdentifier, AggregatedTestResult> tests,
116116
Writer out) throws XMLStreamException {
117117

118-
new XmlReport(out).write(testIdentifier, tests);
118+
try (XmlReport report = new XmlReport(out)) {
119+
report.write(testIdentifier, tests);
120+
}
119121
}
120122

121-
class XmlReport implements AutoCloseable {
123+
private class XmlReport implements AutoCloseable {
122124

123125
private final XMLStreamWriter xml;
124126
private final ReplacingWriter out;

0 commit comments

Comments
 (0)
Please sign in to comment.