Skip to content

Commit

Permalink
Merge pull request #266 from tbradellis/bellis/null-guard-batchdatase…
Browse files Browse the repository at this point in the history
…nder-inputstream

null guard, just print message
  • Loading branch information
jack-berg authored Jan 27, 2021
2 parents e0d20c0 + a8d80e4 commit e4c47c1
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit e4c47c1

Please sign in to comment.