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/09 02:38:38 UTC
[maven-surefire] 01/01: [SUREFIRE-1945] crashed tests - unit tests with large logging output does not produce surefire report
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch SUREFIRE-1945-2223
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit fd9eaea50c323a6f052e2a201440386ad157c8e8
Author: tibor.digana <ti...@apache.org>
AuthorDate: Wed Feb 9 03:30:03 2022 +0100
[SUREFIRE-1945] crashed tests - unit tests with large logging output does not produce surefire report
---
.../surefire/booterclient/output/ThreadedStreamConsumer.java | 10 ++++++++--
.../java/org/apache/maven/surefire/booter/ForkedBooter.java | 11 ++++-------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
index 093c191..672c797 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
@@ -42,6 +42,8 @@ public final class ThreadedStreamConsumer
private static final int ITEM_LIMIT_BEFORE_SLEEP = 10 * 1000;
+ private static final long CLOSE_TIMEOUT_MILLIS = 5 * 60 * 1000L;
+
private final BlockingQueue<String> items = new ArrayBlockingQueue<String>( ITEM_LIMIT_BEFORE_SLEEP );
private final AtomicBoolean stop = new AtomicBoolean();
@@ -136,17 +138,21 @@ public final class ThreadedStreamConsumer
public void close()
throws IOException
{
- if ( stop.compareAndSet( false, true ) )
+ if ( !stop.get() )
{
- items.clear();
try
{
items.put( END_ITEM );
+ thread.join( CLOSE_TIMEOUT_MILLIS );
}
catch ( InterruptedException e )
{
currentThread().interrupt();
}
+ finally
+ {
+ stop.set( true );
+ }
}
if ( pumper.hasErrors() )
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 580132a..3593aa7 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
@@ -43,9 +43,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.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_BYE;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_ERROR;
@@ -69,7 +68,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 = 1000L;
private static final String LAST_DITCH_SHUTDOWN_THREAD = "surefire-forkedjvm-last-ditch-daemon-shutdown-thread-";
private static final String PING_THREAD = "surefire-forkedjvm-ping-";
@@ -331,8 +329,7 @@ public final class ForkedBooter
);
encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n" );
launchLastDitchDaemonShutdownThread( 0 );
- long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS );
- acquireOnePermit( barrier, timeoutMillis );
+ acquireOnePermit( barrier );
cancelPingScheduler();
commandReader.stop();
System.exit( 0 );
@@ -431,11 +428,11 @@ 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( Long.MAX_VALUE, NANOSECONDS );
}
catch ( InterruptedException e )
{