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 03:32:45 UTC
[maven-surefire] 01/01: [SUREFIRE-1631] Forked VM terminated
without properly saying goodbye with AciveMQ
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
commit 17cf2e301cdd8d66032b43d49d4c486c964679f9
Author: tibordigana <ti...@apache.org>
AuthorDate: Tue Nov 12 04:32:32 2019 +0100
[SUREFIRE-1631] Forked VM terminated without properly saying goodbye with AciveMQ
---
.../apache/maven/surefire/booter/PpidChecker.java | 49 ++++++++++++++--------
1 file changed, 31 insertions(+), 18 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 3b5a007..f13da9b 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
@@ -68,6 +68,8 @@ final class PpidChecker
private static final String RELATIVE_PATH_TO_WMIC = "System32\\Wbem";
private static final String SYSTEM_PATH_TO_WMIC =
"%" + WINDOWS_SYSTEM_ROOT_ENV + "%\\" + RELATIVE_PATH_TO_WMIC + "\\";
+ private static final String PS_ETIME_HEADER = "ELAPSED";
+ private static final String PS_PID_HEADER = "PID";
private final Queue<Process> destroyableCommands = new ConcurrentLinkedQueue<>();
@@ -168,20 +170,27 @@ final class PpidChecker
{
if ( previousOutputLine.isInvalid() )
{
- Matcher matcher = UNIX_CMD_OUT_PATTERN.matcher( line );
- if ( matcher.matches() && ppid.equals( fromPID( matcher ) ) )
+ if ( hasHeader )
{
- long pidUptime = fromDays( matcher )
- + fromHours( matcher )
- + fromMinutes( matcher )
- + fromSeconds( matcher );
- return unixProcessInfo( ppid, pidUptime );
+ Matcher matcher = UNIX_CMD_OUT_PATTERN.matcher( line );
+ if ( matcher.matches() && ppid.equals( fromPID( matcher ) ) )
+ {
+ long pidUptime = fromDays( matcher )
+ + fromHours( matcher )
+ + fromMinutes( matcher )
+ + fromSeconds( matcher );
+ return unixProcessInfo( ppid, pidUptime );
+ }
+ matcher = BUSYBOX_CMD_OUT_PATTERN.matcher( line );
+ if ( matcher.matches() && ppid.equals( fromBusyboxPID( matcher ) ) )
+ {
+ long pidUptime = fromBusyboxHours( matcher ) + fromBusyboxMinutes( matcher );
+ return unixProcessInfo( ppid, pidUptime );
+ }
}
- matcher = BUSYBOX_CMD_OUT_PATTERN.matcher( line );
- if ( matcher.matches() && ppid.equals( fromBusyboxPID( matcher ) ) )
+ else
{
- long pidUptime = fromBusyboxHours( matcher ) + fromBusyboxMinutes( matcher );
- return unixProcessInfo( ppid, pidUptime );
+ hasHeader = line.contains( PS_ETIME_HEADER ) && line.contains( PS_PID_HEADER );
}
}
return previousOutputLine;
@@ -195,8 +204,6 @@ final class PpidChecker
{
ProcessInfoConsumer reader = new ProcessInfoConsumer( "US-ASCII" )
{
- private boolean hasHeader;
-
@Override
@Nonnull
ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ) throws Exception
@@ -372,6 +379,8 @@ final class PpidChecker
{
private final String charset;
+ boolean hasHeader;
+
ProcessInfoConsumer( String charset )
{
this.charset = charset;
@@ -409,15 +418,19 @@ final class PpidChecker
DumpErrorSingleton.getSingleton()
.dumpText( out.toString() );
}
- return isStopped() ? ERR_PROCESS_INFO : exitCode == 0 ? processInfo : INVALID_PROCESS_INFO;
+ return isStopped() || !hasHeader
+ ? ERR_PROCESS_INFO : ( exitCode == 0 ? processInfo : INVALID_PROCESS_INFO );
}
catch ( Exception e )
{
- DumpErrorSingleton.getSingleton()
- .dumpText( out.toString() );
+ if ( !( e instanceof InterruptedException ) && !( e.getCause() instanceof InterruptedException ) )
+ {
+ DumpErrorSingleton.getSingleton()
+ .dumpText( out.toString() );
- DumpErrorSingleton.getSingleton()
- .dumpException( e );
+ DumpErrorSingleton.getSingleton()
+ .dumpException( e );
+ }
return ERR_PROCESS_INFO;
}