Closing metricsconfigs.txt

This commit is contained in:
dougqh 2019-11-22 13:08:56 -05:00
parent ce1d6b8460
commit 75727840df
1 changed files with 26 additions and 25 deletions

View File

@ -139,13 +139,13 @@ public class JMXFetch {
} }
private static List<String> getInternalMetricFiles() { private static List<String> getInternalMetricFiles() {
try { final InputStream metricConfigsStream = JMXFetch.class.getResourceAsStream("metricconfigs.txt");
final InputStream metricConfigsStream =
JMXFetch.class.getResourceAsStream("metricconfigs.txt");
if (metricConfigsStream == null) { if (metricConfigsStream == null) {
log.debug("metricconfigs not found. returning empty set"); log.debug("metricconfigs not found. returning empty set");
return Collections.emptyList(); return Collections.emptyList();
} else { }
try {
final String configs = IOUtils.toString(metricConfigsStream, StandardCharsets.UTF_8); final String configs = IOUtils.toString(metricConfigsStream, StandardCharsets.UTF_8);
final String[] split = configs.split("\n"); final String[] split = configs.split("\n");
final List<String> result = new ArrayList<>(split.length); final List<String> result = new ArrayList<>(split.length);
@ -167,10 +167,11 @@ public class JMXFetch {
} }
} }
return result; return result;
}
} catch (final IOException e) { } catch (final IOException e) {
log.debug("error reading metricconfigs. returning empty set", e); log.debug("error reading metricconfigs. returning empty set", e);
return Collections.emptyList(); return Collections.emptyList();
} finally {
IOUtils.closeQuietly(metricConfigsStream);
} }
} }