@@ -442,7 +442,7 @@ public class Cmd {
442442 * @param id ... unique identificator of the java process
443443 * @return pid of the java process or null if such process isn't found
444444 */
445- static Integer getJavaPid (String id ) {
445+ static Long getJavaPid (String id ) {
446446 if (! platform. isWindows()) {
447447 def p
448448 def jps = DefaultProperties . JAVA_HOME + " ${ platform.sep} bin${ platform.sep} jps"
@@ -465,7 +465,7 @@ public class Cmd {
465465 }
466466 String o = t. nextElement()
467467 // expects format pid ....
468- return Integer . valueOf (o)
468+ return Long . parseLong (o)
469469 }
470470 }
471471
@@ -475,7 +475,7 @@ public class Cmd {
475475 * TODO variant only for PID
476476 *
477477 */
478- static int kill (Integer pid , winappname ) {
478+ static int kill (Long pid , winappname ) {
479479 log. debug(" Forcibly killing process with PID=${ pid} , Window title=${ winappname} " )
480480 // TODO: Get rid of black magic :-(
481481 if (platform. isRHEL()) {
@@ -495,7 +495,7 @@ public class Cmd {
495495 * returns kill process exit code. If PID is not defined on non-windows platform, -1 is returned
496496 * TODO: properly implement it for Unix/Linux systems as pkill -P kills only processes with given parent PID, it doesn't go recursively killing from bottom to top
497497 */
498- static int killTree (Integer pid , winappname ) {
498+ static Long killTree (Long pid , winappname ) {
499499 if (platform. isWindows()) {
500500 if (pid != null ) {
501501 log. debug(" killtree(): MS Windows taskkill command: taskkill /PID ${ pid} /f /t" )
@@ -564,7 +564,7 @@ public class Cmd {
564564 log. debug(" Process {} is already dead" , process)
565565 return false
566566 }
567- int pid = ProcessUtils . getProcessId(process)
567+ long pid = ProcessUtils . getProcessId(process)
568568 if (pid == ProcessUtils . UNDEFINED_PROCESS_ID ) {
569569 log. warn(" Failed to extract pid from process" )
570570 return false
@@ -573,7 +573,7 @@ public class Cmd {
573573 return destroyProcessWithTree(pid)
574574 }
575575
576- private static synchronized boolean destroyProcessWithTree (final Integer pid ) {
576+ private static synchronized boolean destroyProcessWithTree (final Long pid ) {
577577 // getting tree of processes running under launched cmd
578578 ListProcess listProcessUtil = new ListProcess ();
579579 List<Map<PsCmdFormat , String > > processTree = listProcessUtil. listProcessTree(pid);
@@ -594,10 +594,10 @@ public class Cmd {
594594 killBuilder. addProcessId(pid);
595595 return Cmd . executeCommand(killBuilder. build(). getCommandLine(), new File (" ." )) != null
596596 } else {
597- int [] processTreePidArray = new int [processTree. size()];
597+ long [] processTreePidArray = new long [processTree. size()];
598598 int i = 0 ;
599599 for (Map<PsCmdFormat , String > processTreeRecord : processTree) {
600- processTreePidArray[i++ ] = Integer . valueOf( processTreeRecord. get(PsCmdFormat . PROCESS_ID ) );
600+ processTreePidArray[i++ ] = processTreeRecord. get(PsCmdFormat . PROCESS_ID );
601601 }
602602 log. debug(" *nix platform: destroying process tree of {} as list of pids {}" ,
603603 pid, processTreePidArray);
@@ -742,16 +742,16 @@ public class Cmd {
742742 }
743743
744744
745- static Set<Integer > retrievePidsByRegexpFromProcOutput (Process proc , regexp ) {
746- Set<Integer > pids = new HashSet<> ()
745+ static Set<Long > retrievePidsByRegexpFromProcOutput (Process proc , regexp ) {
746+ Set<Long > pids = new HashSet<> ()
747747
748748 proc. in . eachLine { line ->
749749 log. debug(" Found process to matching ${ regexp} : ${ line} " )
750750 def match = line =~ regexp
751751 if (match. groupCount() > 0 && match. size() > 0 && match[0 ]. size() > 0 ) {
752752 String pid = match[0 ][1 ]
753753 try {
754- pids. add(Integer . parseInt (pid))
754+ pids. add(Long . parseLong (pid))
755755 } catch (NumberFormatException ex) {
756756 log. debug(" We don't care that line contained an invalid processCode to parse: ${ pid} . Continuing..." )
757757 }
@@ -761,9 +761,9 @@ public class Cmd {
761761 }
762762
763763
764- static Integer extractPid (identifier ) {
764+ static Long extractPid (identifier ) {
765765 log. debug(" Extracting pid using identifier ${ identifier} " )
766- List<Integer > pids = extractPids(identifier, false )
766+ List<Long > pids = extractPids(identifier, false )
767767 if (pids. isEmpty()) {
768768 return null
769769 }
@@ -788,8 +788,8 @@ public class Cmd {
788788 }
789789 }
790790
791- static List<Integer > extractUNIXPids (identifier , getAll = true ) {
792- List<Integer > pids = []
791+ static List<Long > extractUNIXPids (identifier , getAll = true ) {
792+ List<Long > pids = []
793793 final String ALL_FAILED = " All pid extraction options have failed, including the last resort 'pargs' one. This means that the application the pid of which we were trying to" +
794794 " extract hadn't been started in a supported way. Hint: domain.sh? any custom launch script?"
795795 /**
@@ -841,7 +841,7 @@ public class Cmd {
841841 /**
842842 * Now, we will collect all java processes.
843843 */
844- List<Integer > javaPids = []
844+ List<Long > javaPids = []
845845 proc2. in . eachLine { line ->
846846 def match = line =~ psRegExp
847847 log. trace(" Java processes match.groupCount(): ${ match.groupCount()} " )
@@ -852,7 +852,7 @@ public class Cmd {
852852 }
853853 String pid = match[0 ][1 ]
854854 try {
855- javaPids. add(Integer . parseInt (pid))
855+ javaPids. add(Long . parseLong (pid))
856856 } catch (NumberFormatException ex) {
857857 log. error(" Error trying to parse process ID from: \" ${ pid} \" " )
858858 throw ex
@@ -896,7 +896,7 @@ public class Cmd {
896896 log. trace(" 1) match proc4.text: ${ line} " )
897897 String pid = match[0 ][1 ]
898898 try {
899- pids. add(Integer . parseInt (pid))
899+ pids. add(Long . parseLong (pid))
900900 } catch (NumberFormatException ex) {
901901 log. error(" Error trying to parse process ID from: \" ${ pid} \" " )
902902 throw ex
@@ -906,8 +906,8 @@ public class Cmd {
906906 return pids
907907 }
908908
909- static List<Integer > extractWindowsPids (identifier , getAll = true ) {
910- List<Integer > pids = []
909+ static List<Long > extractWindowsPids (identifier , getAll = true ) {
910+ List<Long > pids = []
911911
912912 /**
913913 * WINDOWS STUFF
@@ -952,7 +952,7 @@ public class Cmd {
952952 if (match. size() > 0 && match[0 ]. size() >= 2 && possibleWindowTitlesIds. any { it == match[0 ][2 ]}) {
953953 String pid = match[0 ][1 ]
954954 try {
955- pids. add(Integer . parseInt (pid))
955+ pids. add(Long . parseLong (pid))
956956 } catch (NumberFormatException ex) {
957957 log. error(" Error trying to parse process ID from: \" ${ pid} \" " )
958958 throw ex
@@ -968,7 +968,7 @@ public class Cmd {
968968 return pids
969969 }
970970
971- static boolean killSpecifiedProcesses (Collection<Integer > pidList = []) {
971+ static boolean killSpecifiedProcesses (Collection<Long > pidList = []) {
972972 if (! pidList) {
973973 log. debug(" No process IDs given => nothing to kill" )
974974 return false
@@ -1012,7 +1012,7 @@ public class Cmd {
10121012 /**
10131013 * Wait until is PID removed from system - at max. timeout
10141014 */
1015- static boolean waitForPidRemoved (Integer pid , int timeout = 30 ) {
1015+ static boolean waitForPidRemoved (Long pid , int timeout = 30 ) {
10161016 if (! pid) return true
10171017 int now = 0
10181018
@@ -1036,11 +1036,11 @@ public class Cmd {
10361036 /**
10371037 * Check if PID exists in a system - process is present in system
10381038 */
1039- static boolean pidExists (Integer pid ) {
1039+ static boolean pidExists (Long pid ) {
10401040 def res = false
10411041
10421042 try {
1043- res = getPidList(). contains(Integer . valueOf( pid) )
1043+ res = getPidList(). contains(pid)
10441044 }
10451045 catch (e) {
10461046 }
@@ -1054,7 +1054,7 @@ public class Cmd {
10541054 *
10551055 * @return true if none of the pids provided exist in the system, false otherwise
10561056 */
1057- static boolean waitForPidsRemoved (List<Integer > pids , int timeout , TimeUnit timeUnit ) {
1057+ static boolean waitForPidsRemoved (List<Long > pids , int timeout , TimeUnit timeUnit ) {
10581058 long maxTime = System . currentTimeMillis() + timeUnit. toMillis(timeout)
10591059 boolean anyPidExist = ! getPidList(). intersect(pids). isEmpty()
10601060 while (anyPidExist && System . currentTimeMillis() <= maxTime) {
@@ -1096,7 +1096,7 @@ public class Cmd {
10961096 /**
10971097 * Extract all PIDS from the underlying system
10981098 */
1099- static List<Integer > getPidList () {
1099+ static List<Long > getPidList () {
11001100 def res = []
11011101 def row = []
11021102 def command
@@ -1118,7 +1118,7 @@ public class Cmd {
11181118 else row = line. split() as List
11191119
11201120 // on all tested system is PID in 2nd col
1121- if (! row[1 ]. contains(" PID" )) res << Integer . parseInt (row[1 ]. replaceAll(' "' , ' ' ))
1121+ if (! row[1 ]. contains(" PID" )) res << Long . parseLong (row[1 ]. replaceAll(' "' , ' ' ))
11221122 }
11231123
11241124 return res
0 commit comments