diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/jvm/ThreadList.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/jvm/ThreadList.java index 355bb530..c45e1e07 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/jvm/ThreadList.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/jvm/ThreadList.java @@ -16,7 +16,6 @@ package com.amazon.opendistro.elasticsearch.performanceanalyzer.jvm; import java.io.BufferedReader; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.management.ManagementFactory; @@ -135,10 +134,15 @@ private static void runAttachDump(String pid, String[] args) { try (InputStream in = ((HotSpotVirtualMachine) vm).remoteDataDump((Object[]) args);) { createMap(in); - vm.detach(); } catch (Exception ex) { LOGGER.debug("Cannot list threads with exception: {}", () -> ex.toString()); } + + try { + vm.detach(); + } catch (Exception ex) { + LOGGER.debug("Failed in VM Detach with exception: {}", () -> ex.toString()); + } } //ThreadMXBean-based info for tid, name and allocs @@ -237,16 +241,13 @@ private static void parseLine(String line) { nameMap.put(t.threadName, t); //XXX: we assume no collisions } - private static void createMap(InputStream in) { - try (BufferedReader br = new BufferedReader(new InputStreamReader(in));) { - String line = null; - while ((line = br.readLine()) != null) { - if (line.contains("tid=")) { - parseLine(line); - } + private static void createMap(InputStream in) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + String line = null; + while ((line = br.readLine()) != null) { + if (line.contains("tid=")) { + parseLine(line); } - } catch (IOException ioe) { - LOGGER.debug("Exception while reading input with Exception: {}", () -> ioe.toString()); } } diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java index 5d2982df..4f26177a 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java @@ -108,7 +108,7 @@ public static void emitMetric(String keyPath, String value) { try { java.nio.file.Files.createDirectories(file.getParentFile().toPath()); } catch (IOException ex) { - LOG.error( + LOG.debug( (Supplier) () -> new ParameterizedMessage( "Error In Creating Directories: {} for keyPath:{}", ex.toString(), keyPath), @@ -120,7 +120,7 @@ public static void emitMetric(String keyPath, String value) { try { tmpFile = writeToTmp(keyPath, value); } catch (Exception ex) { - LOG.error( + LOG.debug( (Supplier) () -> new ParameterizedMessage( "Error in Writing to Tmp File: {} for keyPath:{}", ex.toString(), keyPath), @@ -131,7 +131,7 @@ public static void emitMetric(String keyPath, String value) { try { tmpFile.renameTo(file); } catch (Exception ex) { - LOG.error( + LOG.debug( (Supplier) () -> new ParameterizedMessage( "Error in Renaming Tmp File: {} for keyPath:{}", ex.toString(), keyPath),