mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Ensure that our stuff gets closed when working with Chunklets.
This commit is contained in:
parent
cda3675dc5
commit
5ee440d9a5
@ -249,15 +249,36 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
* @param location Where on the disk to put it
|
* @param location Where on the disk to put it
|
||||||
*/
|
*/
|
||||||
private void serializeChunkletStore(ChunkletStore cStore, File location) {
|
private void serializeChunkletStore(ChunkletStore cStore, File location) {
|
||||||
|
FileOutputStream fileOut = null;
|
||||||
|
ObjectOutputStream objOut = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOut = new FileOutputStream(location);
|
fileOut = new FileOutputStream(location);
|
||||||
ObjectOutputStream objOut = new ObjectOutputStream(fileOut);
|
objOut = new ObjectOutputStream(fileOut);
|
||||||
objOut.writeObject(cStore);
|
objOut.writeObject(cStore);
|
||||||
objOut.close();
|
}
|
||||||
fileOut.close();
|
catch (IOException ex) {
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
if (fileOut != null) {
|
||||||
|
try {
|
||||||
|
fileOut.close();
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objOut != null) {
|
||||||
|
try {
|
||||||
|
objOut.close();
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -266,13 +287,13 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
*/
|
*/
|
||||||
private ChunkletStore deserializeChunkletStore(File location) {
|
private ChunkletStore deserializeChunkletStore(File location) {
|
||||||
ChunkletStore storeIn = null;
|
ChunkletStore storeIn = null;
|
||||||
|
FileInputStream fileIn = null;
|
||||||
|
ObjectInputStream objIn = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileInputStream fileIn = new FileInputStream(location);
|
fileIn = new FileInputStream(location);
|
||||||
ObjectInputStream objIn = new ObjectInputStream(fileIn);
|
objIn = new ObjectInputStream(fileIn);
|
||||||
storeIn = (ChunkletStore) objIn.readObject();
|
storeIn = (ChunkletStore) objIn.readObject();
|
||||||
objIn.close();
|
|
||||||
fileIn.close();
|
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
if (ex instanceof EOFException) {
|
if (ex instanceof EOFException) {
|
||||||
@ -296,6 +317,25 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
if (fileIn != null) {
|
||||||
|
try {
|
||||||
|
fileIn.close();
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objIn != null) {
|
||||||
|
try {
|
||||||
|
objIn.close();
|
||||||
|
}
|
||||||
|
catch (IOException ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return storeIn;
|
return storeIn;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user