* Avoid FD leaking in binary importer/exporter

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10768 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
sha..RD 2013-09-13 00:29:59 +00:00
parent d6a1b63206
commit f94bc8660c
2 changed files with 15 additions and 7 deletions

View File

@ -332,9 +332,13 @@ public class BinaryExporter implements JmeExporter {
} }
FileOutputStream fos = new FileOutputStream(f); FileOutputStream fos = new FileOutputStream(f);
boolean rVal = save(object, fos); try {
return save(object, fos);
} finally {
if (fos != null) {
fos.close(); fos.close();
return rVal; }
}
} }
public BinaryOutputCapsule getCapsule(Savable object) { public BinaryOutputCapsule getCapsule(Savable object) {

View File

@ -267,9 +267,13 @@ public final class BinaryImporter implements JmeImporter {
public Savable load(File f, ReadListener listener) throws IOException { public Savable load(File f, ReadListener listener) throws IOException {
FileInputStream fis = new FileInputStream(f); FileInputStream fis = new FileInputStream(f);
Savable rVal = load(fis, listener); try {
return load(fis, listener);
} finally {
if (fis != null) {
fis.close(); fis.close();
return rVal; }
}
} }
public Savable load(byte[] data) throws IOException { public Savable load(byte[] data) throws IOException {