diff --git a/telemetry-core/src/main/java/com/newrelic/telemetry/transport/BatchDataSender.java b/telemetry-core/src/main/java/com/newrelic/telemetry/transport/BatchDataSender.java index 46a3a10b..372f8495 100644 --- a/telemetry-core/src/main/java/com/newrelic/telemetry/transport/BatchDataSender.java +++ b/telemetry-core/src/main/java/com/newrelic/telemetry/transport/BatchDataSender.java @@ -35,6 +35,7 @@ public class BatchDataSender { private static final Logger logger = LoggerFactory.getLogger(BatchDataSender.class); private static final String MEDIA_TYPE = "application/json; charset=utf-8"; + private static final String UNKNOWN_VERSION = "UnknownVersion"; static final String BASE_USER_AGENT_VALUE; @@ -234,10 +235,14 @@ private static String readVersion() { BatchDataSender.class .getClassLoader() .getResourceAsStream("telemetry.sdk.version.properties"); + + if (in == null) { + return UNKNOWN_VERSION; + } return new BufferedReader(new InputStreamReader(in)).readLine().trim(); } catch (Exception e) { - logger.error("Error reading version. Defaulting to 'UnknownVersion'", e); - return "UnknownVersion"; + logger.error(String.format("Error reading version. Defaulting to '%s'", UNKNOWN_VERSION), e); + return UNKNOWN_VERSION; } } }