This is an automated email from the ASF dual-hosted git repository.

olamy pushed a commit to branch test-junit-platform-runner-junit4-parallel-stack
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit d1cc77af8c41c668b6d17a9ac6cd09cbd70b6c60
Author: Olivier Lamy <[email protected]>
AuthorDate: Fri Dec 26 19:04:46 2025 +1000

    remove now useless code
    
    Signed-off-by: Olivier Lamy <[email protected]>
---
 .mvn/extensions.xml                                |   7 +-
 .mvn/maven.config                                  |   1 +
 .../surefire/report/ConsoleOutputFileReporter.java | 109 ++++++++-------------
 .../report/ConsoleOutputFileReporterTest.java      |  33 +++++--
 4 files changed, 70 insertions(+), 80 deletions(-)

diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
index b384bb06c..ce6ab5116 100644
--- a/.mvn/extensions.xml
+++ b/.mvn/extensions.xml
@@ -20,11 +20,16 @@
   <extension>
     <groupId>eu.maveniverse.maven.mimir</groupId>
     <artifactId>extension3</artifactId>
-    <version>0.10.4</version>
+    <version>0.11.0</version>
   </extension>
   <extension>
     <groupId>org.apache.maven.extensions</groupId>
     <artifactId>maven-build-cache-extension</artifactId>
     <version>1.2.1</version>
   </extension>
+  <extension>
+    <groupId>eu.maveniverse.maven.turbo-builder</groupId>
+    <artifactId>maven-turbo-builder</artifactId>
+    <version>0.13</version>
+  </extension>
 </extensions>
diff --git a/.mvn/maven.config b/.mvn/maven.config
new file mode 100644
index 000000000..1d6061320
--- /dev/null
+++ b/.mvn/maven.config
@@ -0,0 +1 @@
+-Daether.dependencyCollector.impl=bf
\ No newline at end of file
diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index 556c35c18..99aeac7c9 100644
--- 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -27,10 +27,8 @@
 import java.nio.file.Files;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicStampedReference;
 
 import 
org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
-import org.apache.maven.surefire.api.report.ReportEntry;
 import org.apache.maven.surefire.api.report.TestOutputReportEntry;
 import org.apache.maven.surefire.api.report.TestSetReportEntry;
 
@@ -55,9 +53,6 @@ public class ConsoleOutputFileReporter implements 
TestcycleConsoleOutputReceiver
     private final Integer forkNumber;
     private final String encoding;
 
-    private final AtomicStampedReference<FilterOutputStream> fileOutputStream =
-            new AtomicStampedReference<>(null, OPEN);
-
     private final Map<String, FilterOutputStream> outputStreams = new 
ConcurrentHashMap<>();
 
     private volatile String reportEntryName;
@@ -76,29 +71,41 @@ public ConsoleOutputFileReporter(
     }
 
     @Override
-    public synchronized void testSetStarting(TestSetReportEntry reportEntry) {
-        closeNullReportFile(reportEntry);
+    public void testSetStarting(TestSetReportEntry reportEntry) {
+        String className = usePhrasedFileName ? reportEntry.getSourceText() : 
reportEntry.getSourceName();
+        try {
+            File file = getReportFile(reportsDirectory, className, 
reportNameSuffix, "-output.txt");
+            if (!reportsDirectory.exists()) {
+                Files.createDirectories(reportsDirectory.toPath());
+            }
+            if (!Files.exists(file.toPath())) {
+                Files.createFile(file.toPath());
+            }
+            outputStreams.put(
+                    className, new 
BufferedOutputStream(Files.newOutputStream(file.toPath()), STREAM_BUFFER_SIZE));
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     @Override
     public void testSetCompleted(TestSetReportEntry report) {}
 
     @Override
-    public synchronized void close() {
-        // The close() method is called in main Thread T2.
-        closeReportFile();
+    public void close() {
+        // Close all output streams in the map
+        for (FilterOutputStream stream : outputStreams.values()) {
+            try {
+                stream.close();
+            } catch (IOException e) {
+                dumpException(e);
+            }
+        }
     }
 
     @Override
     public synchronized void writeTestOutput(TestOutputReportEntry 
reportEntry) {
         try {
-            // This method is called in single thread T1 per fork JVM (see 
ThreadedStreamConsumer).
-            // The close() method is called in main Thread T2.
-            int[] status = new int[1];
-            fileOutputStream.get(status);
-            if (status[0] == CLOSED) {
-                return;
-            }
 
             // Determine the target class name based on stack trace or 
reportEntryName
             String targetClassName = 
extractTestClassFromStack(reportEntry.getStack());
@@ -153,17 +160,25 @@ private String extractTestClassFromStack(String stack) {
         // We look for the test class which typically is the first entry or an 
entry with "Test" in the name
         String[] entries = stack.split(";");
         for (String entry : entries) {
+            //            int hashIndex = entry.indexOf('#');
+            //            if (hashIndex > 0) {
+            //                String className = entry.substring(0, hashIndex);
+            //                // Skip JDK classes and known framework classes
+            //                if (!className.startsWith("java.")
+            //                        && !className.startsWith("sun.")
+            //                        && !className.startsWith("jdk.")
+            //                        && !className.startsWith("org.junit.")
+            //                        && !className.startsWith("junit.")
+            //                        && 
!className.startsWith("org.apache.maven.surefire.")
+            //                        && 
!className.startsWith("org.apache.maven.shadefire.")) {
+            //                    return className;
+            //                }
+            //            }
+
             int hashIndex = entry.indexOf('#');
             if (hashIndex > 0) {
                 String className = entry.substring(0, hashIndex);
-                // Skip JDK classes and known framework classes
-                if (!className.startsWith("java.")
-                        && !className.startsWith("sun.")
-                        && !className.startsWith("jdk.")
-                        && !className.startsWith("org.junit.")
-                        && !className.startsWith("junit.")
-                        && !className.startsWith("org.apache.maven.surefire.")
-                        && 
!className.startsWith("org.apache.maven.shadefire.")) {
+                if (outputStreams.containsKey(className)) {
                     return className;
                 }
             }
@@ -171,50 +186,6 @@ private String extractTestClassFromStack(String stack) {
         return null;
     }
 
-    @SuppressWarnings("checkstyle:emptyblock")
-    private void closeNullReportFile(ReportEntry reportEntry) {
-        try {
-            // close null-output.txt report file
-            close(true);
-        } catch (IOException e) {
-            dumpException(e);
-        } finally {
-            // prepare <class>-output.txt report file
-            reportEntryName = usePhrasedFileName ? reportEntry.getSourceText() 
: reportEntry.getSourceName();
-        }
-    }
-
-    @SuppressWarnings("checkstyle:emptyblock")
-    private void closeReportFile() {
-        try {
-            close(false);
-        } catch (IOException e) {
-            dumpException(e);
-        }
-    }
-
-    private void close(boolean closeReattempt) throws IOException {
-        int[] status = new int[1];
-        FilterOutputStream os = fileOutputStream.get(status);
-        if (status[0] != CLOSED) {
-            fileOutputStream.set(null, closeReattempt ? CLOSED_TO_REOPEN : 
CLOSED);
-            if (os != null && status[0] == OPEN) {
-                os.close();
-            }
-            // Close all output streams in the map
-            for (FilterOutputStream stream : outputStreams.values()) {
-                try {
-                    stream.close();
-                } catch (IOException e) {
-                    dumpException(e);
-                }
-            }
-            if (!closeReattempt) {
-                outputStreams.clear();
-            }
-        }
-    }
-
     private void dumpException(IOException e) {
         if (forkNumber == null) {
             InPluginProcessDumpSingleton.getSingleton().dumpException(e, 
e.getLocalizedMessage(), reportsDirectory);
diff --git 
a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
 
b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
index ca9382fb5..9aa552686 100644
--- 
a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
+++ 
b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
@@ -20,7 +20,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -47,8 +49,10 @@ public class ConsoleOutputFileReporterTest extends TestCase {
      */
     public void testFileNameWithoutSuffix() throws IOException {
         File reportDir = new File(new File(System.getProperty("user.dir"), 
"target"), "tmp1");
-        //noinspection ResultOfMethodCallIgnored
-        reportDir.mkdirs();
+        if (Files.exists(reportDir.toPath())) {
+            FileUtils.deleteDirectory(reportDir);
+        }
+        Files.createDirectories(reportDir.toPath());
         TestSetReportEntry reportEntry = new SimpleReportEntry(
                 NORMAL_RUN, 1L, getClass().getName(), null, 
getClass().getName(), null);
         ConsoleOutputFileReporter reporter = new 
ConsoleOutputFileReporter(reportDir, null, false, null, "UTF-8");
@@ -74,6 +78,10 @@ public void testFileNameWithoutSuffix() throws IOException {
      */
     public void testFileNameWithSuffix() throws IOException {
         File reportDir = new File(new File(System.getProperty("user.dir"), 
"target"), "tmp2");
+        if (Files.exists(reportDir.toPath())) {
+            FileUtils.deleteDirectory(reportDir);
+        }
+        Files.createDirectories(reportDir.toPath());
         String suffixText = "sampleSuffixText";
         TestSetReportEntry reportEntry = new SimpleReportEntry(
                 NORMAL_RUN, 1L, getClass().getName(), null, 
getClass().getName(), null);
@@ -100,6 +108,10 @@ public void testFileNameWithSuffix() throws IOException {
 
     public void testNullReportFile() throws IOException {
         File reportDir = new File(new File(System.getProperty("user.dir"), 
"target"), "tmp3");
+        if (Files.exists(reportDir.toPath())) {
+            FileUtils.deleteDirectory(reportDir);
+        }
+        Files.createDirectories(reportDir.toPath());
         ConsoleOutputFileReporter reporter = new 
ConsoleOutputFileReporter(reportDir, null, false, null, "UTF-8");
         reporter.writeTestOutput((TestOutputReportEntry) stdOut("some text"));
         reporter.testSetCompleted(new SimpleReportEntry(
@@ -120,25 +132,26 @@ public void testNullReportFile() throws IOException {
 
     public void testConcurrentAccessReportFile() throws Exception {
         File reportDir = new File(new File(System.getProperty("user.dir"), 
"target"), "tmp4");
+        if (Files.exists(reportDir.toPath())) {
+            FileUtils.deleteDirectory(reportDir);
+        }
         final ConsoleOutputFileReporter reporter = new 
ConsoleOutputFileReporter(reportDir, null, false, null, "UTF-8");
         reporter.testSetStarting(new SimpleReportEntry(
                 NORMAL_RUN, 1L, getClass().getName(), null, 
getClass().getName(), null));
         ExecutorService scheduler = Executors.newFixedThreadPool(10);
-        final ArrayList<Callable<Void>> jobs = new ArrayList<>();
+        List<Callable<Void>> jobs = new ArrayList<>();
         for (int i = 0; i < 10; i++) {
-            jobs.add(new Callable<Void>() {
-                @Override
-                public Void call() {
-                    reporter.writeTestOutput((TestOutputReportEntry) 
stdOut("some text\n"));
-                    return null;
-                }
+            jobs.add(() -> {
+                reporter.writeTestOutput((TestOutputReportEntry) stdOut("some 
text\n"));
+                return null;
             });
         }
         scheduler.invokeAll(jobs);
         scheduler.shutdown();
         reporter.close();
 
-        File expectedReportFile = new File(reportDir, getClass().getName() + 
"-output.txt");
+        File expectedReportFile =
+                new File(reportDir, 
"org.apache.maven.surefire.report.ConsoleOutputFileReporterTest-output.txt");
 
         assertTrue(
                 "Report file (" + expectedReportFile.getAbsolutePath() + ") 
doesn't exist",

Reply via email to