mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 08:45:11 +00:00
Fix memory leaks by closing streams
This commit is contained in:
1 parent
39e51bc8c2
commit
540508a2be
18 files changed
+96
-60
No files matched your search
@@ -184,7 +184,10 @@ public class PlayerDataController {
|
||||
try {
|
||||
File file = new File(saveDir, filename);
|
||||
if (file.exists()) {
|
||||
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
NBTTagCompound comp;
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
comp = CompressedStreamTools.readCompressed(fis);
|
||||
}
|
||||
file.delete();
|
||||
file = new File(saveDir, filename + "_old");
|
||||
if (file.exists())
|
||||
@@ -197,7 +200,9 @@ public class PlayerDataController {
|
||||
try {
|
||||
File file = new File(saveDir, filename + "_old");
|
||||
if (file.exists()) {
|
||||
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
return CompressedStreamTools.readCompressed(fis);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in new issue
Block a user