Copilot commented on code in PR #3649:
URL: https://github.com/apache/maven-surefire/pull/3649#discussion_r4731143852
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java:
##########
@@ -122,7 +137,11 @@ public synchronized void
writeTestOutput(TestOutputReportEntry reportEntry) {
reportsDirectory.mkdirs();
}
File file = getReportFile(reportsDirectory, className,
reportNameSuffix, "-output.txt");
- return new
BufferedOutputStream(Files.newOutputStream(file.toPath()), STREAM_BUFFER_SIZE);
+ // late output for a class that is done goes after what
its file already has
+ OutputStream out = startedClasses.contains(className)
+ ? Files.newOutputStream(file.toPath(), CREATE,
APPEND)
+ : Files.newOutputStream(file.toPath());
+ return new BufferedOutputStream(out, STREAM_BUFFER_SIZE);
Review Comment:
Late output reopens and caches a completed class's buffered stream, which is
not closed when another class completes. Background output from multiple
finished classes therefore accumulates open files and buffers until
`reporter.close()`, and small late writes remain buffered until then. Treat a
previously started class with no open stream as completed, and append its late
output using try-with-resources instead of caching another stream.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]