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 2019/11/12 12:55:37 UTC
[maven-surefire] branch SUREFIRE-1631 updated: fix
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch SUREFIRE-1631
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/SUREFIRE-1631 by this push:
new 105707a fix
105707a is described below
commit 105707a0e06d3d59da2e0bad725d53cc22a6173d
Author: tibordigana <ti...@apache.org>
AuthorDate: Tue Nov 12 13:55:29 2019 +0100
fix
---
.../apache/maven/surefire/booter/PpidChecker.java | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
index c764977..0d0eb28 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
@@ -84,10 +84,9 @@ final class PpidChecker
private final String ppid;
- private final AtomicBoolean isFirstCheckFailed = new AtomicBoolean();
-
private volatile ProcessInfo parentProcessInfo;
private volatile boolean stopped;
+ private volatile boolean isFirstCheckFailed;
PpidChecker( @Nonnull String ppid )
{
@@ -96,7 +95,7 @@ final class PpidChecker
boolean canUse()
{
- if ( isStopped() || isFirstCheckFailed.get() )
+ if ( isStopped() || isFirstCheckFailed )
{
return false;
}
@@ -128,7 +127,13 @@ final class PpidChecker
// let's compare creation time, should be same unless killed or PID is reused by OS into another process
boolean isAlive = !parentProcessInfo.isInvalid()
&& ( previousInfo == null || parentProcessInfo.isTimeEqualTo( previousInfo ) );
- isFirstCheckFailed.compareAndSet( false, previousInfo == null && !isAlive );
+
+ if ( !isFirstCheckFailed )
+ {
+ isFirstCheckFailed = previousInfo == null && !isAlive;
+ throw new IllegalStateException( "irrelevant to call isProcessAlive(), first check failed" );
+ }
+
return isAlive;
}
else if ( IS_OS_UNIX )
@@ -139,7 +144,13 @@ final class PpidChecker
// let's compare elapsed time, should be greater or equal if parent process is the same and still alive
boolean isAlive = !parentProcessInfo.isInvalid()
&& ( previousInfo == null || !parentProcessInfo.isTimeBefore( previousInfo ) );
- isFirstCheckFailed.compareAndSet( false, previousInfo == null && !isAlive );
+
+ if ( !isFirstCheckFailed )
+ {
+ isFirstCheckFailed = previousInfo == null && !isAlive;
+ throw new IllegalStateException( "irrelevant to call isProcessAlive(), first check failed" );
+ }
+
return isAlive;
}
parentProcessInfo = ERR_PROCESS_INFO;