From 1fef255d77774ba94121bbaa4e5b9ecdbece4b6a Mon Sep 17 00:00:00 2001 From: aumgn Date: Mon, 27 Aug 2012 12:46:56 +0200 Subject: [PATCH] Clean up some io close() calls --- .../wepif/FlatFilePermissionsResolver.java | 20 +++++++++---------- .../worldedit/data/LegacyChunkStore.java | 2 +- .../worldedit/data/McRegionChunkStore.java | 2 +- .../schematic/MCEditSchematicFormat.java | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java b/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java index 15fb3e751..aca21f199 100644 --- a/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java +++ b/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java @@ -69,11 +69,11 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { public Map> loadGroupPermissions() { Map> userGroupPermissions = new HashMap>(); - FileReader input = null; + BufferedReader buff = null; try { - input = new FileReader(this.groupFile); - BufferedReader buff = new BufferedReader(input); + FileReader input = new FileReader(this.groupFile); + buff = new BufferedReader(input); String line; while ((line = buff.readLine()) != null) { @@ -101,8 +101,8 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { e.printStackTrace(); } finally { try { - if (input != null) { - input.close(); + if (buff != null) { + buff.close(); } } catch (IOException e2) { } @@ -122,11 +122,11 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { defaultPermissionsCache = userGroupPermissions.get("default"); } - FileReader input = null; + BufferedReader buff = null; try { - input = new FileReader(this.userFile); - BufferedReader buff = new BufferedReader(input); + FileReader input = new FileReader(this.userFile); + buff = new BufferedReader(input); String line; while ((line = buff.readLine()) != null) { @@ -166,8 +166,8 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { e.printStackTrace(); } finally { try { - if (input != null) { - input.close(); + if (buff != null) { + buff.close(); } } catch (IOException e2) { } diff --git a/src/main/java/com/sk89q/worldedit/data/LegacyChunkStore.java b/src/main/java/com/sk89q/worldedit/data/LegacyChunkStore.java index 3c6e8b43c..2107404db 100644 --- a/src/main/java/com/sk89q/worldedit/data/LegacyChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/data/LegacyChunkStore.java @@ -120,7 +120,7 @@ public abstract class LegacyChunkStore extends ChunkStore { return rootTag; } finally { - stream.close(); + nbt.close(); } } diff --git a/src/main/java/com/sk89q/worldedit/data/McRegionChunkStore.java b/src/main/java/com/sk89q/worldedit/data/McRegionChunkStore.java index 8bbb75b0a..58c161f7b 100644 --- a/src/main/java/com/sk89q/worldedit/data/McRegionChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/data/McRegionChunkStore.java @@ -104,7 +104,7 @@ public abstract class McRegionChunkStore extends ChunkStore { return rootTag; } finally { - stream.close(); + nbt.close(); } } diff --git a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java index 36c16d9be..16ea19697 100644 --- a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java +++ b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java @@ -68,6 +68,7 @@ public class MCEditSchematicFormat extends SchematicFormat { // Schematic tag CompoundTag schematicTag = (CompoundTag) nbtStream.readTag(); + nbtStream.close(); if (!schematicTag.getName().equals("Schematic")) { throw new DataException("Tag \"Schematic\" does not exist or is not first"); }