Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Bad File Descriptor error due to double VirtualMachineImpl$SocketInputStream.close #20

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
aesgithub marked this conversation as resolved.
Show resolved Hide resolved
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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down