ensure closing of inputstream

This commit is contained in:
Marc Zwart 2018-03-22 12:51:55 +01:00
parent 82e439c14b
commit a22eaff49c

View file

@ -87,11 +87,13 @@ public class GameReplay {
private Game loadGame(UUID gameId) {
InputStream file = null;
InputStream buffer = null;
InputStream gzip = null;
ObjectInput input = null;
try{
file = new FileInputStream("saved/" + gameId.toString() + ".game");
buffer = new BufferedInputStream(file);
input = new CopierObjectInputStream(Main.classLoader, new GZIPInputStream(buffer));
gzip = new GZIPInputStream(buffer);
input = new CopierObjectInputStream(Main.classLoader, gzip);
Game loadGame = (Game) input.readObject();
GameStates states = (GameStates) input.readObject();
loadGame.loadGameStates(states);
@ -107,6 +109,7 @@ public class GameReplay {
StreamUtils.closeQuietly(file);
StreamUtils.closeQuietly(buffer);
StreamUtils.closeQuietly(input);
StreamUtils.closeQuietly(gzip);
}
return null;
}