[Libreoffice-commits] core.git: toolkit/test

Robert Antoni Buj i Gelonch robert.buj at gmail.com
Sun Oct 12 23:56:14 PDT 2014


 toolkit/test/accessibility/Options.java |   35 ++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

New commits:
commit 3c27e31628c49b927d2026176cac5a085bf0fe39
Author: Robert Antoni Buj i Gelonch <robert.buj at gmail.com>
Date:   Sun Oct 12 22:00:41 2014 +0200

    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 at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/toolkit/test/accessibility/Options.java b/toolkit/test/accessibility/Options.java
index 5651928..3b9e537 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)
+            {
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list