[Bleeding] Fixed file handle leak in /timings command. Addresses BUKKIT-853
This commit is contained in:
parent
3440a1f2ee
commit
eb3c161180
@ -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");
|
||||
try {
|
||||
PrintStream fileTimings = new PrintStream(timings);
|
||||
PrintStream fileTimings = null;
|
||||
PrintStream fileNames = null;
|
||||
try {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user