From 0fa642e280856d23ca05ea97053d4b4073925df5 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Wed, 20 Nov 2024 12:44:50 +0100 Subject: [PATCH] Blindly trying to fix the smoke tests --- .../java/datadog/trace/util/PidHelper.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/internal-api/src/main/java/datadog/trace/util/PidHelper.java b/internal-api/src/main/java/datadog/trace/util/PidHelper.java index 19a5c38eba5..c5ca80f0222 100644 --- a/internal-api/src/main/java/datadog/trace/util/PidHelper.java +++ b/internal-api/src/main/java/datadog/trace/util/PidHelper.java @@ -75,23 +75,22 @@ public static Set getJavaPids() { // start draining the subcommand's pipes asynchronously to avoid flooding them CompletableFuture> collecting = CompletableFuture.supplyAsync( - (Supplier>) - () -> { - try (BufferedReader br = - new BufferedReader(new InputStreamReader(p.getInputStream()))) { - return br.lines() - .filter(l -> !l.contains("jps")) - .map( - l -> { - int idx = l.indexOf(' '); - return l.substring(0, idx); - }) - .collect(java.util.stream.Collectors.toSet()); - } catch (IOException e) { - log.debug("Unable to list java processes via 'jps'", e); - return Collections.emptySet(); - } - }); + () -> { + try (BufferedReader br = + new BufferedReader(new InputStreamReader(p.getInputStream()))) { + return br.lines() + .filter(l -> !l.contains("jps")) + .map( + l -> { + int idx = l.indexOf(' '); + return l.substring(0, idx); + }) + .collect(java.util.stream.Collectors.toSet()); + } catch (IOException e) { + log.debug("Unable to list java processes via 'jps'", e); + return Collections.emptySet(); + } + }); if (p.waitFor(500, TimeUnit.MILLISECONDS)) { if (p.exitValue() == 0) { return collecting.get(); @@ -99,6 +98,7 @@ public static Set getJavaPids() { log.debug("Execution of 'jps' failed with exit code {}", p.exitValue()); } } else { + p.destroyForcibly(); log.debug("Execution of 'jps' timed out"); } } catch (Exception e) {