You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/02/21 09:15:06 UTC

[maven-surefire] 01/01: [SUREFIRE-2021] Commands should be flushed immediately. Use Channels.newChannel() instead of newBufferedChannel(). Delete the old flushing mechanism on forked processes.

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

tibordigana pushed a commit to branch event-consumer-isalive
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 1c4e68e17b325e26defd161b80a4638ef6990694
Author: tibor.digana <ti...@apache.org>
AuthorDate: Mon Feb 21 10:14:38 2022 +0100

    [SUREFIRE-2021] Commands should be flushed immediately. Use Channels.newChannel() instead of newBufferedChannel(). Delete the old flushing mechanism on forked processes.
---
 .../booterclient/ClasspathForkConfiguration.java   |  4 +-
 .../booterclient/DefaultForkConfiguration.java     | 14 +++----
 .../surefire/booterclient/ForkConfiguration.java   |  8 ++--
 .../plugin/surefire/booterclient/ForkStarter.java  |  7 +---
 .../booterclient/JarManifestForkConfiguration.java |  4 +-
 .../ModularClasspathForkConfiguration.java         |  4 +-
 .../lazytestprovider/AbstractCommandReader.java    | 34 +++-------------
 ...mFlushableCommandline.java => Commandline.java} | 41 ++++---------------
 .../lazytestprovider/DefaultCommandReader.java     |  2 -
 .../DefferedChannelCommandSender.java              | 35 ----------------
 .../lazytestprovider/FlushReceiver.java            | 38 -----------------
 .../lazytestprovider/FlushReceiverProvider.java    | 34 ----------------
 .../OutputStreamFlushReceiver.java                 | 47 ----------------------
 .../lazytestprovider/TestProvidingInputStream.java |  4 --
 .../booterclient/DefaultForkConfigurationTest.java | 18 ++++-----
 .../booterclient/ForkConfigurationTest.java        | 25 +++++++-----
 .../surefire/booterclient/ForkStarterTest.java     |  6 +--
 .../ModularClasspathForkConfigurationTest.java     |  4 +-
 ...leCommandlineTest.java => CommandlineTest.java} | 35 ++--------------
 .../maven/plugin/surefire/extensions/E2ETest.java  |  5 ---
 .../maven/surefire/extensions/CommandReader.java   |  1 -
 .../extensions/util/CommandlineStreams.java        |  3 +-
 22 files changed, 67 insertions(+), 306 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java
index 9c906c4..1ce9d61 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  * under the License.
  */
 
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.StartupConfiguration;
@@ -58,7 +58,7 @@ public final class ClasspathForkConfiguration
     }
 
     @Override
-    protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+    protected void resolveClasspath( @Nonnull Commandline cli,
                                      @Nonnull String booterThatHasMainMethod,
                                      @Nonnull StartupConfiguration config,
                                      @Nonnull File dumpLogDirectory )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java
index 138e7f3..c7a77e7 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java
@@ -20,7 +20,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  */
 
 import org.apache.maven.plugin.surefire.JdkAttributes;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.surefire.booter.AbstractPathConfiguration;
 import org.apache.maven.surefire.booter.Classpath;
@@ -101,7 +101,7 @@ public abstract class DefaultForkConfiguration
         this.forkNodeFactory = forkNodeFactory;
     }
 
-    protected abstract void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+    protected abstract void resolveClasspath( @Nonnull Commandline cli,
                                               @Nonnull String booterThatHasMainMethod,
                                               @Nonnull StartupConfiguration config,
                                               @Nonnull File dumpLogDirectory )
@@ -129,15 +129,15 @@ public abstract class DefaultForkConfiguration
      */
     @Nonnull
     @Override
-    public OutputStreamFlushableCommandline createCommandLine( @Nonnull StartupConfiguration config,
-                                                               int forkNumber,
-                                                               @Nonnull File dumpLogDirectory )
+    public Commandline createCommandLine( @Nonnull StartupConfiguration config,
+                                          int forkNumber,
+                                          @Nonnull File dumpLogDirectory )
             throws SurefireBooterForkException
     {
         try
         {
-            OutputStreamFlushableCommandline cli =
-                    new OutputStreamFlushableCommandline( getExcludedEnvironmentVariables() );
+            Commandline cli =
+                    new Commandline( getExcludedEnvironmentVariables() );
 
             cli.setWorkingDirectory( getWorkingDirectory( forkNumber ).getAbsolutePath() );
 
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 9fddf96..8378134 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -20,7 +20,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  */
 
 import org.apache.maven.plugin.surefire.JdkAttributes;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.ForkedBooter;
 import org.apache.maven.surefire.booter.StartupConfiguration;
@@ -64,8 +64,8 @@ public abstract class ForkConfiguration
      *          when unable to perform the fork
      */
     @Nonnull
-    public abstract OutputStreamFlushableCommandline createCommandLine( @Nonnull StartupConfiguration config,
-                                                                        int forkNumber,
-                                                                        @Nonnull File dumpLogDirectory )
+    public abstract Commandline createCommandLine( @Nonnull StartupConfiguration config,
+                                                   int forkNumber,
+                                                   @Nonnull File dumpLogDirectory )
             throws SurefireBooterForkException;
 }
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index 29bc31e..2a2c820 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -24,7 +24,7 @@ import org.apache.maven.plugin.surefire.StartupReportConfiguration;
 import org.apache.maven.plugin.surefire.SurefireProperties;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.AbstractCommandReader;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.NotifiableTestStream;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
 import org.apache.maven.plugin.surefire.booterclient.output.ForkClient;
@@ -608,10 +608,7 @@ public class ForkStarter
             throw new SurefireBooterForkException( "Error creating properties files for forking", e );
         }
 
-        OutputStreamFlushableCommandline cli =
-                forkConfiguration.createCommandLine( startupConfiguration, forkNumber, dumpLogDir );
-
-        commandReader.setFlushReceiverProvider( cli );
+        Commandline cli = forkConfiguration.createCommandLine( startupConfiguration, forkNumber, dumpLogDir );
 
         cli.createArg().setValue( tempDir );
         cli.createArg().setValue( DUMP_FILE_PREFIX + forkNumber );
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
index 697b206..50caad0 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
@@ -22,7 +22,7 @@ package org.apache.maven.plugin.surefire.booterclient;
 import org.apache.maven.surefire.shared.compress.archivers.zip.Zip64Mode;
 import org.apache.maven.surefire.shared.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.maven.surefire.shared.compress.archivers.zip.ZipArchiveOutputStream;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.surefire.booter.Classpath;
@@ -81,7 +81,7 @@ public final class JarManifestForkConfiguration
     }
 
     @Override
-    protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+    protected void resolveClasspath( @Nonnull Commandline cli,
                                      @Nonnull String booterThatHasMainMethod,
                                      @Nonnull StartupConfiguration config,
                                      @Nonnull File dumpLogDirectory )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
index fc89016..0fd796c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  * under the License.
  */
 
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.surefire.booter.AbstractPathConfiguration;
@@ -77,7 +77,7 @@ public class ModularClasspathForkConfiguration
     }
 
     @Override
-    protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli, @Nonnull String startClass,
+    protected void resolveClasspath( @Nonnull Commandline cli, @Nonnull String startClass,
                                      @Nonnull StartupConfiguration config, @Nonnull File dumpLogDirectory )
             throws SurefireBooterForkException
     {
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandReader.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandReader.java
index a31e9f7..fbf487b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandReader.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandReader.java
@@ -21,41 +21,17 @@ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
 
 import org.apache.maven.surefire.extensions.CommandReader;
 
-import java.io.IOException;
-
-import static java.util.Objects.requireNonNull;
+import java.io.Closeable;
 
 /**
- * Stream reader returns bytes which ar finally sent to the forked jvm std-input-stream.
+ * Stream reader returns bytes which are finally sent to the forked jvm std-input-stream.
+ * Physical implementation of command sender:<br>
+ * Instance of {@link AbstractCommandReader} (namely {@link TestLessInputStream} or {@link TestProvidingInputStream}).
  *
  * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
  * @since 2.19
  */
 public abstract class AbstractCommandReader
-        implements CommandReader, DefferedChannelCommandSender
+        implements CommandReader, NotifiableTestStream, Closeable
 {
-    private volatile FlushReceiverProvider flushReceiverProvider;
-
-    /**
-     * @param flushReceiverProvider the provider for a flush receiver.
-     */
-    @Override
-    public void setFlushReceiverProvider( FlushReceiverProvider flushReceiverProvider )
-    {
-        this.flushReceiverProvider = requireNonNull( flushReceiverProvider );
-    }
-
-    @Override
-    public void tryFlush()
-        throws IOException
-    {
-        if ( flushReceiverProvider != null )
-        {
-            FlushReceiver flushReceiver = flushReceiverProvider.getFlushReceiver();
-            if ( flushReceiver != null )
-            {
-                flushReceiver.flush();
-            }
-        }
-    }
 }
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/Commandline.java
similarity index 65%
rename from maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
rename to maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/Commandline.java
index b54e185..bbc14bf 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/Commandline.java
@@ -20,44 +20,39 @@ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
  */
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedDeque;
 
-import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
 import org.apache.maven.surefire.shared.utils.cli.CommandLineUtils;
-import org.apache.maven.surefire.shared.utils.cli.Commandline;
+
+import static java.util.Collections.addAll;
 
 /**
- * A {@link Commandline} implementation that provides the output stream of
- * the executed process in form of a {@link FlushReceiver}, for it to be
- * flushed on demand.
+ * A {@link org.apache.maven.surefire.shared.utils.cli.Commandline} implementation.
  *
  * @author Andreas Gudian
  */
-public class OutputStreamFlushableCommandline
-    extends Commandline
-    implements FlushReceiverProvider
+public class Commandline
+    extends org.apache.maven.surefire.shared.utils.cli.Commandline
 {
     private final Collection<String> excludedEnvironmentVariables;
     private final Set<String> addedEnvironmentVariables;
-    private volatile FlushReceiver flushReceiver;
 
     /**
      * for testing purposes only
      */
-    public OutputStreamFlushableCommandline()
+    public Commandline()
     {
         this( new String[0] );
     }
 
-    public OutputStreamFlushableCommandline( String[] excludedEnvironmentVariables )
+    public Commandline( String[] excludedEnvironmentVariables )
     {
         this.excludedEnvironmentVariables = new ConcurrentLinkedDeque<>();
         addedEnvironmentVariables = new HashSet<>();
-        Collections.addAll( this.excludedEnvironmentVariables, excludedEnvironmentVariables );
+        addAll( this.excludedEnvironmentVariables, excludedEnvironmentVariables );
     }
 
     @Override
@@ -80,24 +75,4 @@ public class OutputStreamFlushableCommandline
             }
         }
     }
-
-    @Override
-    public Process execute()
-        throws CommandLineException
-    {
-        Process process = super.execute();
-
-        if ( process.getOutputStream() != null )
-        {
-            flushReceiver = new OutputStreamFlushReceiver( process.getOutputStream() );
-        }
-
-        return process;
-    }
-
-    @Override
-    public FlushReceiver getFlushReceiver()
-    {
-        return flushReceiver;
-    }
 }
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/DefaultCommandReader.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/DefaultCommandReader.java
index 5d9dc4c..60dbd01 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/DefaultCommandReader.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/DefaultCommandReader.java
@@ -65,8 +65,6 @@ public abstract class DefaultCommandReader
     public Command readNextCommand()
         throws IOException
     {
-        tryFlush();
-
         if ( isClosed() )
         {
             return null;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/DefferedChannelCommandSender.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/DefferedChannelCommandSender.java
deleted file mode 100644
index e489caa..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/DefferedChannelCommandSender.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Closeable;
-
-/**
- * Physical implementation of command sender.<br>
- * Instance of {@link AbstractCommandReader} (namely {@link TestLessInputStream} or {@link TestProvidingInputStream}).
- *
- * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
- * @since 3.0.0-M4
- */
-public interface DefferedChannelCommandSender
-    extends NotifiableTestStream, Closeable
-{
-    void setFlushReceiverProvider( FlushReceiverProvider flushReceiverProvider );
-}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java
deleted file mode 100644
index a7aa62e..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-/**
- * Something that can be flushed.
- *
- * @author Andreas Gudian
- */
-public interface FlushReceiver
-{
-    /**
-     * Performs a flush, releasing any buffered resources.
-     *
-     * @throws IOException in case the flush operation failed
-     */
-    void flush()
-        throws IOException;
-}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java
deleted file mode 100644
index 96ea32c..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Provides a {@link FlushReceiver}.
- *
- * @author Andreas Gudian
- */
-public interface FlushReceiverProvider
-{
-
-    /**
-     * @return a {@link FlushReceiver}
-     */
-    FlushReceiver getFlushReceiver();
-}
\ No newline at end of file
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushReceiver.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushReceiver.java
deleted file mode 100644
index 131661d..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushReceiver.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Facade flushing {@link OutputStream} and isolating the stream in client.
- */
-final class OutputStreamFlushReceiver
-        implements FlushReceiver
-{
-    private final OutputStream outputStream;
-
-    /**
-     * Wraps an output stream in order to delegate a flush.
-     */
-    OutputStreamFlushReceiver( OutputStream outputStream )
-    {
-        this.outputStream = outputStream;
-    }
-
-    @Override
-    public void flush()
-            throws IOException
-    {
-        outputStream.flush();
-    }
-}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index a23c2ff..1be8e6b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -40,10 +40,6 @@ import static org.apache.maven.surefire.api.booter.Command.toShutdown;
  * <br>
  * The Stream provides only one test at a time, but only after {@link #provideNewTest()} has been invoked.
  * <br>
- * After providing each test class name, followed by a newline character, a flush is performed on the
- * {@link FlushReceiver} provided by the {@link FlushReceiverProvider} that can be set using
- * {@link #setFlushReceiverProvider(FlushReceiverProvider)}.
- * <br>
  * The instance is used only in reusable forks in {@link org.apache.maven.plugin.surefire.booterclient.ForkStarter}
  * by one Thread.
  *
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
index 0288db1..ad66885 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  * under the License.
  */
 
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.plugin.surefire.util.Relocator;
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
@@ -111,7 +111,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -136,7 +136,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -161,7 +161,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -186,7 +186,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -212,7 +212,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -237,7 +237,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -262,7 +262,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -287,7 +287,7 @@ public class DefaultForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
index 0784cf9..d177188 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
@@ -20,7 +20,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  */
 
 import org.apache.maven.plugin.surefire.JdkAttributes;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
@@ -32,7 +32,6 @@ import org.apache.maven.surefire.booter.StartupConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.apache.maven.surefire.extensions.ForkNodeFactory;
 import org.apache.maven.surefire.shared.io.FileUtils;
-import org.apache.maven.surefire.shared.utils.cli.Commandline;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -109,7 +108,7 @@ public class ForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -129,7 +128,8 @@ public class ForkConfigurationTest
         ClassLoaderConfiguration clc = new ClassLoaderConfiguration( true, true );
         StartupConfiguration startup = new StartupConfiguration( "cls", cpConfig, clc, ALL, providerJpmsArgs );
 
-        Commandline cli = config.createCommandLine( startup, 1, getTempDirectory() );
+        org.apache.maven.surefire.shared.utils.cli.Commandline
+                cli = config.createCommandLine( startup, 1, getTempDirectory() );
 
         assertThat( cli.getEnvironmentVariables() )
             .contains( "key1=val1", "key2=val2", "key3=val3" )
@@ -159,7 +159,8 @@ public class ForkConfigurationTest
         ClassLoaderConfiguration clc = new ClassLoaderConfiguration( true, true );
         StartupConfiguration startup = new StartupConfiguration( "cls", cpConfig, clc, ALL, providerJpmsArgs );
 
-        Commandline cli = config.createCommandLine( startup, 1, getTempDirectory() );
+        org.apache.maven.surefire.shared.utils.cli.Commandline
+                cli = config.createCommandLine( startup, 1, getTempDirectory() );
         String cliAsString = cli.toString();
 
         assertThat( cliAsString )
@@ -194,7 +195,7 @@ public class ForkConfigurationTest
         {
 
             @Override
-            protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli,
+            protected void resolveClasspath( @Nonnull Commandline cli,
                                              @Nonnull String booterThatHasMainMethod,
                                              @Nonnull StartupConfiguration config,
                                              @Nonnull File dumpLogDirectory )
@@ -236,7 +237,8 @@ public class ForkConfigurationTest
         assertThat( startup.isShadefire() )
             .isFalse();
 
-        Commandline cli = config.createCommandLine( startup, 1, getTempDirectory() );
+        org.apache.maven.surefire.shared.utils.cli.Commandline
+                cli = config.createCommandLine( startup, 1, getTempDirectory() );
 
         assertThat( cli.toString() )
             .contains( "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" );
@@ -257,7 +259,8 @@ public class ForkConfigurationTest
         StartupConfiguration startup =
             new StartupConfiguration( "", cpConfig, clc, ALL, Collections.<String[]>emptyList() );
 
-        Commandline cli = config.createCommandLine( startup, 1, getTempDirectory() );
+        org.apache.maven.surefire.shared.utils.cli.Commandline
+                cli = config.createCommandLine( startup, 1, getTempDirectory() );
 
         String line = join( " ", cli.getCommandline() );
         assertTrue( line.contains( "-jar" ) );
@@ -278,7 +281,8 @@ public class ForkConfigurationTest
         StartupConfiguration startup =
             new StartupConfiguration( "", cpConfig, clc, ALL, Collections.<String[]>emptyList() );
 
-        Commandline commandLine = config.createCommandLine( startup, 1, getTempDirectory() );
+        org.apache.maven.surefire.shared.utils.cli.Commandline
+                commandLine = config.createCommandLine( startup, 1, getTempDirectory() );
         assertThat( commandLine.toString() ).contains( IS_OS_WINDOWS ? "abc def" : "'abc' 'def'" );
     }
 
@@ -294,7 +298,8 @@ public class ForkConfigurationTest
         StartupConfiguration startup =
             new StartupConfiguration( "", cpConfig, clc, ALL, Collections.<String[]>emptyList() );
         ForkConfiguration config = getForkConfiguration( cwd.getCanonicalFile() );
-        Commandline commandLine = config.createCommandLine( startup, 1, getTempDirectory() );
+        org.apache.maven.surefire.shared.utils.cli.Commandline
+                commandLine = config.createCommandLine( startup, 1, getTempDirectory() );
 
         File forkDirectory = new File( basedir, "fork_1" );
 
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkStarterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkStarterTest.java
index 3584755..ff04152 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkStarterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkStarterTest.java
@@ -22,7 +22,7 @@ package org.apache.maven.plugin.surefire.booterclient;
 import org.apache.maven.plugin.surefire.StartupReportConfiguration;
 import org.apache.maven.plugin.surefire.SurefireProperties;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.AbstractCommandReader;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream.TestLessInputStreamBuilder;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
@@ -149,7 +149,7 @@ public class ForkStarterTest
             .thenReturn( tmp );
         when( forkConfiguration.getPluginPlatform() )
             .thenReturn( new Platform() );
-        OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
+        Commandline cli = new Commandline();
         cli.setWorkingDirectory( tmp );
         cli.setExecutable( System.getProperty( "java.home" ) + "/bin/java" );
         cli.createArg().setLine( "-jar" );
@@ -215,7 +215,7 @@ public class ForkStarterTest
             .thenReturn( tmp );
         when( forkConfiguration.getPluginPlatform() )
             .thenReturn( new Platform() );
-        OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
+        Commandline cli = new Commandline();
         cli.setWorkingDirectory( tmp );
         cli.setExecutable( System.getProperty( "java.home" ) + "/bin/java" );
         cli.createArg().setLine( "-jar" );
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
index 14ea562..6688591 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  * under the License.
  */
 
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.Commandline;
 import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
 import org.apache.maven.surefire.booter.Classpath;
@@ -145,7 +145,7 @@ public class ModularClasspathForkConfigurationTest
         ClassLoaderConfiguration clc = new ClassLoaderConfiguration( true, true );
         StartupConfiguration startupConfiguration = new StartupConfiguration( "JUnitCoreProvider",
             modularClasspathConfiguration, clc, null, Collections.<String[]>emptyList() );
-        OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
+        Commandline cli = new Commandline();
         config.resolveClasspath( cli, ForkedBooter.class.getName(), startupConfiguration,
                 createTempFile( "surefire", "surefire-reports" ) );
 
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandlineTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/CommandlineTest.java
similarity index 71%
rename from maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandlineTest.java
rename to maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/CommandlineTest.java
index 3388924..86d3f3c 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandlineTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/CommandlineTest.java
@@ -23,26 +23,18 @@ import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
 import org.assertj.core.api.Condition;
 import org.junit.Test;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
 import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.powermock.api.mockito.PowerMockito.mock;
-import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;
 
 /**
  *
  */
-public class OutputStreamFlushableCommandlineTest
+public class CommandlineTest
 {
-
     @Test
     public void shouldGetEnvironmentVariables()
     {
-        OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
+        Commandline cli = new Commandline();
         String[] env = cli.getEnvironmentVariables();
 
         assertThat( env )
@@ -50,7 +42,7 @@ public class OutputStreamFlushableCommandlineTest
                 .satisfies( new ContainsAnyStartsWith( "JAVA_HOME=" ) );
 
         String[] excluded = { "JAVA_HOME" };
-        cli = new OutputStreamFlushableCommandline( excluded );
+        cli = new Commandline( excluded );
         env = cli.getEnvironmentVariables();
 
         assertThat( env )
@@ -61,29 +53,10 @@ public class OutputStreamFlushableCommandlineTest
     @Test
     public void shouldExecute() throws CommandLineException
     {
-        OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
+        Commandline cli = new Commandline();
         cli.getShell().setWorkingDirectory( System.getProperty( "user.dir" ) );
         cli.getShell().setExecutable( IS_OS_WINDOWS ? "dir" : "ls" );
-        assertThat( cli.getFlushReceiver() ).isNull();
         cli.execute();
-        assertThat( cli.getFlushReceiver() ).isNotNull();
-    }
-
-    @Test
-    public void shouldGetFlushReceiver()
-    {
-        OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
-        assertThat( cli.getFlushReceiver() ).isNull();
-    }
-
-    @Test
-    public void shouldFlush() throws IOException
-    {
-        ByteArrayOutputStream os = mock( ByteArrayOutputStream.class );
-        OutputStreamFlushReceiver flushReceiver = new OutputStreamFlushReceiver( os );
-        verifyZeroInteractions( os );
-        flushReceiver.flush();
-        verify( os, times( 1 ) ).flush();
     }
 
     private static final class ContainsAnyStartsWith extends Condition<Object[]>
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/E2ETest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/E2ETest.java
index 0fc5051..d3a3b72 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/E2ETest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/E2ETest.java
@@ -366,11 +366,6 @@ public class E2ETest
         {
             return false;
         }
-
-        @Override
-        public void tryFlush()
-        {
-        }
     }
 
     private static class DummyCloseable implements Closeable
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/CommandReader.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/CommandReader.java
index 32cb3a2..ecc7282 100644
--- a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/CommandReader.java
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/CommandReader.java
@@ -42,5 +42,4 @@ public interface CommandReader extends Closeable
     @Override
     void close();
     boolean isClosed();
-    void tryFlush() throws IOException;
 }
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineStreams.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineStreams.java
index 315720e..634ed64 100644
--- a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineStreams.java
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineStreams.java
@@ -29,6 +29,7 @@ import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
 
 import static org.apache.maven.surefire.api.util.internal.Channels.newBufferedChannel;
+import static org.apache.maven.surefire.api.util.internal.Channels.newChannel;
 
 /**
  *
@@ -48,7 +49,7 @@ public final class CommandlineStreams implements Closeable
         InputStream stdErrStream = process.getErrorStream();
         stdErrChannel = newBufferedChannel( stdErrStream );
 
-        stdInChannel = newBufferedChannel( process.getOutputStream() );
+        stdInChannel = newChannel( process.getOutputStream() );
     }
 
     public ReadableByteChannel getStdOutChannel()