@@ -75,30 +75,30 @@ public static Set<String> getJavaPids() {
7575 // start draining the subcommand's pipes asynchronously to avoid flooding them
7676 CompletableFuture <Set <String >> collecting =
7777 CompletableFuture .supplyAsync (
78- (Supplier <Set <String >>)
79- () -> {
80- try (BufferedReader br =
81- new BufferedReader (new InputStreamReader (p .getInputStream ()))) {
82- return br .lines ()
83- .filter (l -> !l .contains ("jps" ))
84- .map (
85- l -> {
86- int idx = l .indexOf (' ' );
87- return l .substring (0 , idx );
88- })
89- .collect (java .util .stream .Collectors .toSet ());
90- } catch (IOException e ) {
91- log .debug ("Unable to list java processes via 'jps'" , e );
92- return Collections .emptySet ();
93- }
94- });
78+ () -> {
79+ try (BufferedReader br =
80+ new BufferedReader (new InputStreamReader (p .getInputStream ()))) {
81+ return br .lines ()
82+ .filter (l -> !l .contains ("jps" ))
83+ .map (
84+ l -> {
85+ int idx = l .indexOf (' ' );
86+ return l .substring (0 , idx );
87+ })
88+ .collect (java .util .stream .Collectors .toSet ());
89+ } catch (IOException e ) {
90+ log .debug ("Unable to list java processes via 'jps'" , e );
91+ return Collections .emptySet ();
92+ }
93+ });
9594 if (p .waitFor (500 , TimeUnit .MILLISECONDS )) {
9695 if (p .exitValue () == 0 ) {
9796 return collecting .get ();
9897 } else {
9998 log .debug ("Execution of 'jps' failed with exit code {}" , p .exitValue ());
10099 }
101100 } else {
101+ p .destroyForcibly ();
102102 log .debug ("Execution of 'jps' timed out" );
103103 }
104104 } catch (Exception e ) {
0 commit comments