From bcbb53b7deb9d45a2833eb4755a2f39860ae05b6 Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Wed, 30 Dec 2015 21:28:54 -0500 Subject: [PATCH] close log file stream --- .../apache/cassandra/stress/StressGraph.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/stress/src/org/apache/cassandra/stress/StressGraph.java b/tools/stress/src/org/apache/cassandra/stress/StressGraph.java index 4e7fd12074..ebaa0aecdb 100644 --- a/tools/stress/src/org/apache/cassandra/stress/StressGraph.java +++ b/tools/stress/src/org/apache/cassandra/stress/StressGraph.java @@ -234,28 +234,28 @@ public class StressGraph private JSONObject createJSONStats(JSONObject json) { - JSONArray stats; - if (json == null) + try (InputStream logStream = new FileInputStream(stressSettings.graph.temporaryLogFile)) { - json = new JSONObject(); - stats = new JSONArray(); - } - else - { - stats = (JSONArray) json.get("stats"); - } + JSONArray stats; + if (json == null) + { + json = new JSONObject(); + stats = new JSONArray(); + } + else + { + stats = (JSONArray) json.get("stats"); + } - try - { - stats = parseLogStats(new FileInputStream(stressSettings.graph.temporaryLogFile), stats); + stats = parseLogStats(logStream, stats); + + json.put("title", stressSettings.graph.title); + json.put("stats", stats); + return json; } - catch (FileNotFoundException e) + catch (IOException e) { throw new RuntimeException(e); } - - json.put("title", stressSettings.graph.title); - json.put("stats", stats); - return json; } }