summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-12-07 00:08:14 +0100
committersnowleo <schneeleo@gmail.com>2011-12-07 00:08:45 +0100
commit854fc05c5b3a3d1d1ed40a0755eac401043b92b4 (patch)
treec1574e3e7d0239d0f0a8f308a86b0dbb096200e7
parentb9077d91a57a47b0762681fde382e8a392c7bc46 (diff)
downloadEssentials-854fc05c5b3a3d1d1ed40a0755eac401043b92b4.tar
Essentials-854fc05c5b3a3d1d1ed40a0755eac401043b92b4.tar.gz
Essentials-854fc05c5b3a3d1d1ed40a0755eac401043b92b4.tar.lz
Essentials-854fc05c5b3a3d1d1ed40a0755eac401043b92b4.tar.xz
Essentials-854fc05c5b3a3d1d1ed40a0755eac401043b92b4.zip
Fix serious bug in Dev2.7.137 - Dev2.7.144: if spawn.yml is not present, the server will run into a deadlock.
-rw-r--r--Essentials/src/com/earth2me/essentials/storage/AbstractDelayedYamlFileReader.java39
1 files changed, 19 insertions, 20 deletions
diff --git a/Essentials/src/com/earth2me/essentials/storage/AbstractDelayedYamlFileReader.java b/Essentials/src/com/earth2me/essentials/storage/AbstractDelayedYamlFileReader.java
index 1f2887d88..43bfc358d 100644
--- a/Essentials/src/com/earth2me/essentials/storage/AbstractDelayedYamlFileReader.java
+++ b/Essentials/src/com/earth2me/essentials/storage/AbstractDelayedYamlFileReader.java
@@ -6,6 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
+import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.yaml.snakeyaml.error.YAMLException;
@@ -30,39 +31,37 @@ public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> imp
@Override
public void run()
{
- FileReader reader = null;
+ onStart();
try
{
- onStart();
+ final FileReader reader = new FileReader(file);
try
{
- reader = new FileReader(file);
- T object = new YamlStorageReader(reader, plugin).load(clazz);
+ final T object = new YamlStorageReader(reader, plugin).load(clazz);
onSuccess(object);
}
- catch (ObjectLoadException ex)
+ finally
{
- onException();
- Bukkit.getLogger().log(Level.SEVERE, "File broken: " + file.toString(), ex.getCause());
+ try
+ {
+ reader.close();
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, "File can't be closed: " + file.toString(), ex);
+ }
}
+
}
catch (FileNotFoundException ex)
{
- Bukkit.getLogger().log(Level.SEVERE, file.toString(), ex);
+ onException();
+ Bukkit.getLogger().log(Level.WARNING, "File not found: " + file.toString());
}
- finally
+ catch (ObjectLoadException ex)
{
- try
- {
- if (reader != null)
- {
- reader.close();
- }
- }
- catch (IOException ex)
- {
- Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
- }
+ onException();
+ Bukkit.getLogger().log(Level.SEVERE, "File broken: " + file.toString(), ex.getCause());
}
}