@@ -127,9 +127,9 @@ class DumpHangedTestPlugin : Plugin<Project> {
127127 val allJavaProcessesFile = file(" all-java-processes" )
128128 runCmd(Redirect .to(allJavaProcessesFile), " jcmd" , " -l" )
129129
130- // On IBM JDK javacore can be collected by signaling the matching `Gradle Test Executor` process with `kill -3`.
130+ // On IBM JDK thread dump can be collected by signaling the matching `Gradle Test Executor` process with `kill -3`.
131131 // It will be writen into `/tmp/javacore.YYYYMMDD.HHMMSS.PID.SEQ.txt
132- if (isIbm8Run (allJavaProcessesFile)) {
132+ if (isIbm8 (allJavaProcessesFile)) {
133133 val allProcessesFile = file(" all-processes" )
134134 runCmd(Redirect .to(allProcessesFile), " ps" , " -ef" )
135135 extractPidsIbm8(allProcessesFile).forEach { ibm8Pid ->
@@ -183,7 +183,7 @@ class DumpHangedTestPlugin : Plugin<Project> {
183183 }
184184 }
185185
186- private fun isIbm8Run (file : File ): Boolean =
186+ private fun isIbm8 (file : File ): Boolean =
187187 file.readLines().any { it.contains(" -PtestJvm=ibm8" ) }
188188
189189 private fun extractPids (file : File ): List <String > =
@@ -201,7 +201,9 @@ class DumpHangedTestPlugin : Plugin<Project> {
201201 .toList()
202202 }
203203
204- // ps -ef format starts with: UID PID PPID ...
204+ private val whitespaceRegex = Regex (" \\ s+" )
205+
206+ // ps -ef format produce output like: UID PID PPID ...
205207 private fun extractPid (line : String ): String? =
206- line.trim ().split(Regex ( " \\ s+ " ) ).getOrNull(1 )
208+ line.trimStart ().split(whitespaceRegex, limit = 3 ).getOrNull(1 )
207209}
0 commit comments