From c3495efb802cd9394cd5ee3bc8f7d0e3e7d144aa Mon Sep 17 00:00:00 2001 From: "minkee.lee" Date: Tue, 7 Oct 2014 16:22:50 +0900 Subject: [PATCH] Refactoring: Close property file handle after modify vm. Change-Id: I2c24e82a3a5da5c8738a3f11262eee5699a816bb Signed-off-by: minkee.lee --- .../org/tizen/emulator/manager/vms/EmulatorVMList.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/common-project/src/org/tizen/emulator/manager/vms/EmulatorVMList.java b/common-project/src/org/tizen/emulator/manager/vms/EmulatorVMList.java index 8bfc448..170e425 100644 --- a/common-project/src/org/tizen/emulator/manager/vms/EmulatorVMList.java +++ b/common-project/src/org/tizen/emulator/manager/vms/EmulatorVMList.java @@ -34,6 +34,7 @@ import java.io.File; import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -221,6 +222,7 @@ public class EmulatorVMList { outputFile = property.getPropertyFile(); } + FileOutputStream fos = null; try { Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); @@ -230,15 +232,25 @@ public class EmulatorVMList { property.getPropertyFile().getParentFile().mkdirs(); } - marshaller.marshal(property.getConfiguration(), new FileOutputStream(outputFile)); + fos = new FileOutputStream(outputFile); + marshaller.marshal(property.getConfiguration(), fos); } catch (JAXBException e) { e.printStackTrace(); - return false; + } catch (FileNotFoundException e) { e.printStackTrace(); - return false; + + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + EMLogger.getLogger().warning("ERROR : " + e.getMessage()); + return false; + } + } } return true; -- 2.7.4