Close underlying stream on exception in FileStorage

This commit is contained in:
Lukas Rieger (Blue) 2022-01-09 15:54:06 +01:00
parent 8d87d3e930
commit acb7cf1e7b
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -65,7 +65,13 @@ public OutputStream writeMapTile(String mapId, TileType tileType, Vector2i tile)
OutputStream os = AtomicFileHelper.createFilepartOutputStream(file);
os = new BufferedOutputStream(os);
os = compression.compress(os);
try {
os = compression.compress(os);
} catch (IOException ex) {
os.close();
throw ex;
}
return os;
}