@@ -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,9 +852,9 @@ 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) {
857- throw new NumberFormatException (" Guys, I can't parse Integer from:${ pid} " , ex)
857+ throw new NumberFormatException (" Guys, I can't parse Long from:${ pid} " , ex)
858858 }
859859 }
860860
@@ -895,17 +895,17 @@ public class Cmd {
895895 log. trace(" 1) match proc4.text: ${ line} " )
896896 String pid = match[0 ][1 ]
897897 try {
898- pids. add(Integer . parseInt (pid))
898+ pids. add(Long . parseLong (pid))
899899 } catch (NumberFormatException ex) {
900- throw new NumberFormatException (" Guys, I can't parse Integer from:${ pid} " , ex)
900+ throw new NumberFormatException (" Guys, I can't parse Long from:${ pid} " , ex)
901901 }
902902 }
903903
904904 return pids
905905 }
906906
907- static List<Integer > extractWindowsPids (identifier , getAll = true ) {
908- List<Integer > pids = []
907+ static List<Long > extractWindowsPids (identifier , getAll = true ) {
908+ List<Long > pids = []
909909
910910 /**
911911 * WINDOWS STUFF
@@ -950,9 +950,9 @@ public class Cmd {
950950 if (match. size() > 0 && match[0 ]. size() >= 2 && possibleWindowTitlesIds. any { it == match[0 ][2 ]}) {
951951 String pid = match[0 ][1 ]
952952 try {
953- pids. add(Integer . parseInt (pid))
953+ pids. add(Long . parseLong (pid))
954954 } catch (NumberFormatException ex) {
955- throw new NumberFormatException (" Guys, I can't parse Integer from:${ pid} " , ex)
955+ throw new NumberFormatException (" Guys, I can't parse Long from:${ pid} " , ex)
956956 }
957957 } else {
958958 log. error(" WIDLE match didn't succeed :-) it was: match.size():${ match.size()} " )
@@ -965,7 +965,7 @@ public class Cmd {
965965 return pids
966966 }
967967
968- static boolean killSpecifiedProcesses (Collection<Integer > pidList = []) {
968+ static boolean killSpecifiedProcesses (Collection<Long > pidList = []) {
969969 if (! pidList) {
970970 log. debug(" No process IDs given => nothing to kill" )
971971 return false
@@ -1009,7 +1009,7 @@ public class Cmd {
10091009 /**
10101010 * Wait until is PID removed from system - at max. timeout
10111011 */
1012- static boolean waitForPidRemoved (Integer pid , int timeout = 30 ) {
1012+ static boolean waitForPidRemoved (Long pid , int timeout = 30 ) {
10131013 if (! pid) return true
10141014 int now = 0
10151015
@@ -1033,11 +1033,11 @@ public class Cmd {
10331033 /**
10341034 * Check if PID exists in a system - process is present in system
10351035 */
1036- static boolean pidExists (Integer pid ) {
1036+ static boolean pidExists (Long pid ) {
10371037 def res = false
10381038
10391039 try {
1040- res = getPidList(). contains(Integer . valueOf( pid) )
1040+ res = getPidList(). contains(pid)
10411041 }
10421042 catch (e) {
10431043 }
@@ -1051,7 +1051,7 @@ public class Cmd {
10511051 *
10521052 * @return true if none of the pids provided exist in the system, false otherwise
10531053 */
1054- static boolean waitForPidsRemoved (List<Integer > pids , int timeout , TimeUnit timeUnit ) {
1054+ static boolean waitForPidsRemoved (List<Long > pids , int timeout , TimeUnit timeUnit ) {
10551055 long maxTime = System . currentTimeMillis() + timeUnit. toMillis(timeout)
10561056 boolean anyPidExist = getPidList(). intersect(pids). isEmpty()
10571057 while (anyPidExist && System . currentTimeMillis() <= maxTime) {
@@ -1093,7 +1093,7 @@ public class Cmd {
10931093 /**
10941094 * Extract all PIDS from the underlying system
10951095 */
1096- static List<Integer > getPidList () {
1096+ static List<Long > getPidList () {
10971097 def res = []
10981098 def row = []
10991099 def command
@@ -1115,7 +1115,7 @@ public class Cmd {
11151115 else row = line. split() as List
11161116
11171117 // on all tested system is PID in 2nd col
1118- if (! row[1 ]. contains(" PID" )) res << Integer . parseInt (row[1 ]. replaceAll(' "' , ' ' ))
1118+ if (! row[1 ]. contains(" PID" )) res << Long . parseLong (row[1 ]. replaceAll(' "' , ' ' ))
11191119 }
11201120
11211121 return res
0 commit comments