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 2020/07/08 13:37:15 UTC

[maven-surefire] branch flush created (now 50bc56d)

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

tibordigana pushed a change to branch flush
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


      at 50bc56d  simple flush proposal

This branch includes the following new commits:

     new 50bc56d  simple flush proposal

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-surefire] 01/01: simple flush proposal

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 50bc56d4f76c726cbbb472cd98bece268cf38a7c
Author: tibordigana <ti...@apache.org>
AuthorDate: Wed Jul 8 15:37:07 2020 +0200

    simple flush proposal
---
 ...LegacyMasterProcessChannelProcessorFactory.java | 33 +++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/LegacyMasterProcessChannelProcessorFactory.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/LegacyMasterProcessChannelProcessorFactory.java
index 1344f3d..e7eb3db 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/LegacyMasterProcessChannelProcessorFactory.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/spi/LegacyMasterProcessChannelProcessorFactory.java
@@ -21,12 +21,18 @@ package org.apache.maven.surefire.booter.spi;
 
 import org.apache.maven.surefire.api.booter.MasterProcessChannelDecoder;
 import org.apache.maven.surefire.api.booter.MasterProcessChannelEncoder;
+import org.apache.maven.surefire.api.util.internal.WritableBufferedByteChannel;
 import org.apache.maven.surefire.spi.MasterProcessChannelProcessorFactory;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.ScheduledExecutorService;
 
+import static java.util.concurrent.Executors.newScheduledThreadPool;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.maven.surefire.api.util.internal.Channels.newBufferedChannel;
+import static org.apache.maven.surefire.api.util.internal.DaemonThreadFactory.newDaemonThreadFactory;
 
 /**
  * Producer of encoder and decoder for process pipes.
@@ -38,6 +44,13 @@ import static org.apache.maven.surefire.api.util.internal.Channels.newBufferedCh
 public class LegacyMasterProcessChannelProcessorFactory
     implements MasterProcessChannelProcessorFactory
 {
+    private final ScheduledExecutorService flusher;
+
+    public LegacyMasterProcessChannelProcessorFactory()
+    {
+        flusher = newScheduledThreadPool( 1, newDaemonThreadFactory() );
+    }
+
     @Override
     public boolean canUse( String channelConfig )
     {
@@ -62,11 +75,29 @@ public class LegacyMasterProcessChannelProcessorFactory
     @Override
     public MasterProcessChannelEncoder createEncoder()
     {
-        return new LegacyMasterProcessChannelEncoder( newBufferedChannel( System.out ) );
+        final WritableBufferedByteChannel channel = newBufferedChannel( System.out );
+        flusher.scheduleWithFixedDelay( new Runnable()
+        {
+            @Override
+            public void run()
+            {
+                try
+                {
+                    channel.write( ByteBuffer.wrap( new byte[] {'\n'} ) );
+                }
+                catch ( IOException e )
+                {
+                    // cannot do anything about this I/O issue
+                }
+            }
+        }, 0L, 100, MILLISECONDS );
+
+        return new LegacyMasterProcessChannelEncoder( channel );
     }
 
     @Override
     public void close()
     {
+        flusher.shutdown();
     }
 }