From 805d5dc5cefcf645e37cb4e4acc546604ceec753 Mon Sep 17 00:00:00 2001 From: Slim Bouguerra Date: Tue, 3 May 2016 09:54:36 -0500 Subject: [PATCH] fix for file not found execption at the graphite extension module --- .../graphite/WhiteListBasedConverter.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/WhiteListBasedConverter.java b/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/WhiteListBasedConverter.java index 7554797944e5..5982a579f8ca 100644 --- a/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/WhiteListBasedConverter.java +++ b/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/WhiteListBasedConverter.java @@ -31,6 +31,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; +import com.google.common.io.CharStreams; import com.google.common.io.Files; import com.metamx.common.ISE; import com.metamx.common.logger.Logger; @@ -38,6 +39,7 @@ import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import java.nio.charset.Charset; import java.util.Collections; import java.util.List; @@ -247,13 +249,16 @@ private ImmutableSortedMap> readMap(final String ma { String fileContent; String actualPath = mapPath; - if (Strings.isNullOrEmpty(mapPath)) { - actualPath = this.getClass().getClassLoader().getResource("defaultWhiteListMap.json").getFile(); - LOGGER.warn("using default whiteList map located at [%s]", actualPath); - } - try { - fileContent = Files.asCharSource(new File(actualPath), Charset.forName("UTF-8")).read(); + if (Strings.isNullOrEmpty(mapPath)) { + actualPath = this.getClass().getClassLoader().getResource("defaultWhiteListMap.json").getFile(); + LOGGER.info("using default whiteList map located at [%s]", actualPath); + fileContent = CharStreams.toString(new InputStreamReader(this.getClass() + .getClassLoader() + .getResourceAsStream("defaultWhiteListMap.json"))); + } else { + fileContent = Files.asCharSource(new File(mapPath), Charset.forName("UTF-8")).read(); + } return mapper.reader(new TypeReference>>() { }).readValue(fileContent);