From d67e9d970da281d96a21f3ef532bda8fee4384ac Mon Sep 17 00:00:00 2001 From: stoneLeaf Date: Sun, 8 May 2011 06:57:08 +0200 Subject: [PATCH 1/2] Corrected a logfile issue. When WorldEdit is reloaded within Bukkit, an additional log file is created. This is because the Logger's FileHandler wasn't closed and thus kept the log file locked. --- .../worldedit/bukkit/BukkitConfiguration.java | 14 +++++++++++--- .../sk89q/worldedit/bukkit/WorldEditPlugin.java | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java index 73d89c77b..43761962e 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.snapshots.SnapshotRepository; public class BukkitConfiguration extends LocalConfiguration { private Configuration config; private Logger logger; + private FileHandler logFileHandler; public boolean noOpPermissions = false; @@ -97,9 +98,9 @@ public class BukkitConfiguration extends LocalConfiguration { String logFile = config.getString("logging.file", ""); if (!logFile.equals("")) { try { - FileHandler handler = new FileHandler(logFile, true); - handler.setFormatter(new LogFormat()); - logger.addHandler(handler); + logFileHandler = new FileHandler(logFile, true); + logFileHandler.setFormatter(new LogFormat()); + logger.addHandler(logFileHandler); } catch (IOException e) { logger.log(Level.WARNING, "Could not use log file " + logFile + ": " + e.getMessage()); @@ -110,4 +111,11 @@ public class BukkitConfiguration extends LocalConfiguration { } } } + + public void unload() { + if (logFileHandler != null) { + logFileHandler.close(); + } + } + } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 5e6dffdc3..2de3daf5c 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -111,6 +111,7 @@ public class WorldEditPlugin extends JavaPlugin { */ public void onDisable() { controller.clearSessions(); + config.unload(); } /** From dae9c1becf195be94a4f7bbbd3cfe323ade34bd6 Mon Sep 17 00:00:00 2001 From: stoneLeaf Date: Sun, 8 May 2011 07:40:20 +0200 Subject: [PATCH 2/2] Corrected a logfile issue (2). An unload() was missing in the case of a '/we reload' command. --- src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 2de3daf5c..97f97b8bf 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -119,6 +119,7 @@ public class WorldEditPlugin extends JavaPlugin { */ protected void loadConfiguration() { getConfiguration().load(); + config.unload(); config.load(); perms.load(); }