diff options
author | Score_Under <seejay.11@gmail.com> | 2012-02-25 17:39:54 +0000 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-02-29 09:52:57 -0500 |
commit | eb3c1611807e4461a5fc1a2880f1533dbdbe7167 (patch) | |
tree | 48e634a6855bbc41138bc8756f2574e8b0120155 | |
parent | 3440a1f2ee543e24224e59356d6eb6f9f58316a3 (diff) | |
download | bukkit-eb3c1611807e4461a5fc1a2880f1533dbdbe7167.tar bukkit-eb3c1611807e4461a5fc1a2880f1533dbdbe7167.tar.gz bukkit-eb3c1611807e4461a5fc1a2880f1533dbdbe7167.tar.lz bukkit-eb3c1611807e4461a5fc1a2880f1533dbdbe7167.tar.xz bukkit-eb3c1611807e4461a5fc1a2880f1533dbdbe7167.zip |
[Bleeding] Fixed file handle leak in /timings command. Addresses BUKKIT-853
-rw-r--r-- | src/main/java/org/bukkit/command/defaults/TimingsCommand.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/TimingsCommand.java b/src/main/java/org/bukkit/command/defaults/TimingsCommand.java index f4da879b..9e5b6769 100644 --- a/src/main/java/org/bukkit/command/defaults/TimingsCommand.java +++ b/src/main/java/org/bukkit/command/defaults/TimingsCommand.java @@ -53,9 +53,10 @@ public class TimingsCommand extends Command { File timings = new File(timingFolder, "timings.txt"); File names = null; while (timings.exists()) timings = new File(timingFolder, "timings" + (++index) + ".txt"); + PrintStream fileTimings = null; + PrintStream fileNames = null; try { - PrintStream fileTimings = new PrintStream(timings); - PrintStream fileNames = null; + fileTimings = new PrintStream(timings); if (separate) { names = new File(timingFolder, "names" + index + ".txt"); fileNames = new PrintStream(names); @@ -87,6 +88,13 @@ public class TimingsCommand extends Command { sender.sendMessage("Timings written to " + timings.getPath()); if (separate) sender.sendMessage("Names written to " + names.getPath()); } catch (IOException e) { + } finally { + if (fileTimings != null) { + fileTimings.close(); + } + if (fileNames != null) { + fileNames.close(); + } } } return true; |