mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Flatfile loadProfile - place newUser() inside of try block
This fixes incorrect behavior in the edge-case where an IOException occurs when reading (but not writing) the flatfile database.
This commit is contained in:
parent
9542d7cd79
commit
c0128c6912
@ -387,22 +387,30 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile p = loadFromLine(character);
|
PlayerProfile p = loadFromLine(character);
|
||||||
in.close();
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Didn't find the player, create a new one
|
||||||
|
if (create) {
|
||||||
|
newUser(playerName);
|
||||||
|
return new PlayerProfile(playerName, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
// Silly inlining of tryClose() because the compiler is giving a warning when I use tryClose()
|
||||||
|
try {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (create) {
|
// Return unloaded profile
|
||||||
newUser(playerName);
|
|
||||||
return new PlayerProfile(playerName, true);
|
|
||||||
}
|
|
||||||
return new PlayerProfile(playerName);
|
return new PlayerProfile(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user