Skip to content
Open
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 @@ -944,8 +944,8 @@ public Map<String, Map<String, List<MetricDefinition>>> getServiceMetrics(String

Gson gson = new Gson();

try {
map = gson.fromJson(new FileReader(svc.getMetricsFile()), type);
try (FileReader reader = new FileReader(svc.getMetricsFile())) {
map = gson.fromJson(reader, type);

svc.setMetrics(processMetricDefinition(map));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ protected Map<String, Object> parseFile(File file) throws IOException {
} else if (!file.isFile() || !file.canRead()) {
throw new IOException(String.format("%s is not a readable file", file.getAbsolutePath()));
} else {
try {
return new Gson().fromJson(new FileReader(file),
try (FileReader reader = new FileReader(file)) {
return new Gson().fromJson(reader,
new TypeToken<Map<String, Object>>() {
}.getType());
} catch (JsonSyntaxException e) {
Expand Down