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/08 20:41:30 UTC

[maven-surefire] branch booter created (now c39fa43)

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

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


      at c39fa43  Very short timeout for BYE_ACK caused that the tests have crashed.

This branch includes the following new commits:

     new c39fa43  Very short timeout for BYE_ACK caused that the tests have crashed.

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: Very short timeout for BYE_ACK caused that the tests have crashed.

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

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

commit c39fa43a338bb1aa7f4aea4573a25c5e19ccdf5e
Author: tibor.digana <ti...@apache.org>
AuthorDate: Tue Feb 8 21:41:12 2022 +0100

    Very short timeout for BYE_ACK caused that the tests have crashed.
---
 .../plugin/surefire/booterclient/output/ForkClient.java    |  2 +-
 .../org/apache/maven/surefire/booter/ForkedBooter.java     | 14 +++++---------
 .../org/apache/maven/surefire/booter/ForkedBooterTest.java |  6 +++---
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index 1011fbf..9a2065b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -310,7 +310,7 @@ public class ForkClient
         public void handle( StackTraceWriter stackTrace )
         {
             getOrCreateConsoleLogger()
-                .error( "System Exit has timed out in the forked process " + forkNumber );
+                .error( "The surefire booter JVM" + forkNumber + " was interrupted and exits." );
         }
     }
 
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 fe64a95..6712ef1 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
@@ -55,10 +55,8 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import static java.lang.Math.max;
 import static java.lang.Thread.currentThread;
 import static java.util.ServiceLoader.load;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.apache.maven.surefire.api.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
 import static org.apache.maven.surefire.api.util.ReflectionUtils.instantiateOneArg;
@@ -83,7 +81,6 @@ public final class ForkedBooter
 {
     private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30L;
     private static final long PING_TIMEOUT_IN_SECONDS = 30L;
-    private static final long ONE_SECOND_IN_MILLIS = 1_000L;
     private static final String LAST_DITCH_SHUTDOWN_THREAD = "surefire-forkedjvm-last-ditch-daemon-shutdown-thread-";
     private static final String PING_THREAD = "surefire-forkedjvm-ping-";
     private static final String PROCESS_CHECKER_THREAD = "surefire-process-checker";
@@ -442,9 +439,8 @@ public final class ForkedBooter
         );
         eventChannel.bye();
         launchLastDitchDaemonShutdownThread( 0 );
-        long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS );
-        boolean timeoutElapsed = !acquireOnePermit( exitBarrier, timeoutMillis );
-        if ( timeoutElapsed && !eventChannel.checkError() )
+        boolean byeAckReceived = acquireOnePermit( exitBarrier );
+        if ( !byeAckReceived && !eventChannel.checkError() )
         {
             eventChannel.sendExitError( null, false );
         }
@@ -616,16 +612,16 @@ public final class ForkedBooter
         return pluginProcessChecker != null && pluginProcessChecker.canUse();
     }
 
-    private static boolean acquireOnePermit( Semaphore barrier, long timeoutMillis )
+    private static boolean acquireOnePermit( Semaphore barrier )
     {
         try
         {
-            return barrier.tryAcquire( timeoutMillis, MILLISECONDS );
+            return barrier.tryAcquire( Integer.MAX_VALUE, SECONDS );
         }
         catch ( InterruptedException e )
         {
             // cancel schedulers, stop the command reader and exit 0
-            return true;
+            return false;
         }
     }
 
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java
index da3516e..b5a1851 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java
@@ -150,7 +150,7 @@ public class ForkedBooterTest
     public void testBarrier1() throws Exception
     {
         Semaphore semaphore = new Semaphore( 2 );
-        boolean acquiredOnePermit = invokeMethod( ForkedBooter.class, "acquireOnePermit", semaphore, 30_000L );
+        boolean acquiredOnePermit = invokeMethod( ForkedBooter.class, "acquireOnePermit", semaphore );
 
         assertThat( acquiredOnePermit ).isTrue();
         assertThat( semaphore.availablePermits() ).isEqualTo( 1 );
@@ -163,9 +163,9 @@ public class ForkedBooterTest
         Thread.currentThread().interrupt();
         try
         {
-            boolean acquiredOnePermit = invokeMethod( ForkedBooter.class, "acquireOnePermit", semaphore, 30_000L );
+            boolean acquiredOnePermit = invokeMethod( ForkedBooter.class, "acquireOnePermit", semaphore );
 
-            assertThat( acquiredOnePermit ).isTrue();
+            assertThat( acquiredOnePermit ).isFalse();
             assertThat( semaphore.availablePermits() ).isEqualTo( 0 );
         }
         finally