diff options
author | Robert Antoni Buj i Gelonch <robert.buj@gmail.com> | 2014-10-12 22:00:41 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2014-10-13 06:55:53 +0000 |
commit | 3c27e31628c49b927d2026176cac5a085bf0fe39 (patch) | |
tree | 8c1c118a20051be04484f7e8c6ccd95e24fa159d /toolkit | |
parent | edb6783c14a9303af000b54ce63f55967289a7a6 (diff) |
accessibility: ensure that the stream is cleaned up before the method returns
Change-Id: Ib46d24be831b5c9bda0582bd7064f34528e1d609
Reviewed-on: https://gerrit.libreoffice.org/11938
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/test/accessibility/Options.java | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/toolkit/test/accessibility/Options.java b/toolkit/test/accessibility/Options.java index 565192817621..3b9e5372c160 100644 --- a/toolkit/test/accessibility/Options.java +++ b/toolkit/test/accessibility/Options.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.util.Properties; /** Load from and save options into a file. @@ -69,24 +70,50 @@ class Options public void Load (String sBaseName) { + FileInputStream fis = null; try { - load (new FileInputStream (ProvideFile(sBaseName))); + fis = new FileInputStream (ProvideFile(sBaseName)); + load (fis); } - catch (java.io.IOException e) + catch (IOException e) { // Ignore a non-existing options file. } + finally + { + try + { + if (fis != null) + fis.close(); + } + catch (IOException ex) + { + } + } } public void Save (String sBaseName) { + FileOutputStream fos = null; try { - store (new FileOutputStream (ProvideFile(sBaseName)), null); + fos = new FileOutputStream (ProvideFile(sBaseName)); + store (fos, null); + } + catch (IOException e) + { } - catch (java.io.IOException e) + finally { + try + { + if (fos != null) + fos.close(); + } + catch (IOException ex) + { + } } } |