Repository: maven-surefire
Updated Branches:
  refs/heads/master bdde67c5c -> e7bb6fc8b


[SUREFIRE-1354] Sometimes BYE_ACK command is lost


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/e7bb6fc8
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/e7bb6fc8
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/e7bb6fc8

Branch: refs/heads/master
Commit: e7bb6fc8b37bd9057c0baa25ce1cb2f16d643e63
Parents: bdde67c
Author: Tibor17 <tibo...@lycos.com>
Authored: Thu Apr 6 00:10:11 2017 +0200
Committer: Tibor17 <tibo...@lycos.com>
Committed: Thu Apr 6 00:10:11 2017 +0200

----------------------------------------------------------------------
 .../apache/maven/surefire/booter/ForkedBooter.java    | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e7bb6fc8/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
----------------------------------------------------------------------
diff --git 
a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
 
b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 4589088..fef21d1 100644
--- 
a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ 
b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -156,10 +156,7 @@ public final class ForkedBooter
                 encode( stringBuilder, stackTraceWriter, false );
                 encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + 
stringBuilder + "\n", originalOut );
             }
-            // Say bye.
-            encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n", 
originalOut );
-            // noinspection CallToSystemExit
-            exit( 0, reader );
+            acknowledgedExit( reader, originalOut );
         }
         catch ( Throwable t )
         {
@@ -258,7 +255,7 @@ public final class ForkedBooter
         System.exit( returnCode );
     }
 
-    private static void exit( int returnCode, final CommandReader reader )
+    private static void acknowledgedExit( CommandReader reader, PrintStream 
originalOut )
     {
         final Semaphore barrier = new Semaphore( 0 );
         reader.addByeAckListener( new CommandListener()
@@ -270,10 +267,11 @@ public final class ForkedBooter
                                       }
                                   }
         );
-        launchLastDitchDaemonShutdownThread( returnCode );
-        final long timeoutMillis = max( systemExitTimeoutInSeconds * 
ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS );
+        encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n", 
originalOut );
+        launchLastDitchDaemonShutdownThread( 0 );
+        long timeoutMillis = max( systemExitTimeoutInSeconds * 
ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS );
         acquireOnePermit( barrier, timeoutMillis );
-        System.exit( returnCode );
+        System.exit( 0 );
     }
 
     private static boolean acquireOnePermit( Semaphore barrier, long 
timeoutMillis )

Reply via email to