Fix serious bug in Dev2.7.137 - Dev2.7.144: if spawn.yml is not present, the server will run into a deadlock.

This commit is contained in:
snowleo 2011-12-07 00:08:14 +01:00
parent b9077d91a5
commit 854fc05c5b

View File

@ -6,6 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.error.YAMLException;
@ -30,39 +31,37 @@ public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> imp
@Override @Override
public void run() public void run()
{ {
FileReader reader = null; onStart();
try try
{ {
onStart(); final FileReader reader = new FileReader(file);
try try
{ {
reader = new FileReader(file); final T object = new YamlStorageReader(reader, plugin).load(clazz);
T object = new YamlStorageReader(reader, plugin).load(clazz);
onSuccess(object); onSuccess(object);
} }
catch (ObjectLoadException ex) finally
{ {
onException(); try
Bukkit.getLogger().log(Level.SEVERE, "File broken: " + file.toString(), ex.getCause());
}
}
catch (FileNotFoundException ex)
{
Bukkit.getLogger().log(Level.SEVERE, file.toString(), ex);
}
finally
{
try
{
if (reader != null)
{ {
reader.close(); reader.close();
} }
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, "File can't be closed: " + file.toString(), ex);
}
} }
catch (IOException ex)
{ }
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex); catch (FileNotFoundException ex)
} {
onException();
Bukkit.getLogger().log(Level.WARNING, "File not found: " + file.toString());
}
catch (ObjectLoadException ex)
{
onException();
Bukkit.getLogger().log(Level.SEVERE, "File broken: " + file.toString(), ex.getCause());
} }
} }