Bug 1251213 - release resources from fis. r=sebastian
authorAndi-Bogdan Postelnicu <bogdan.postelnicu@softvision.ro>
Wed, 02 Mar 2016 11:02:44 +0200
changeset 323110 5b643385e0da9986ffd55806d3fc860c8a6dfa54
parent 323109 82320c90069949c1db523d61563aa8ddd367e64e
child 323111 c3b74646acc84a71a98c2b160dc302337788a96c
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1251213
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1251213 - release resources from fis. r=sebastian MozReview-Commit-ID: 9RTJprP6rh2
build/mobile/sutagent/android/DoCommand.java
--- a/build/mobile/sutagent/android/DoCommand.java
+++ b/build/mobile/sutagent/android/DoCommand.java
@@ -2848,29 +2848,29 @@ private void CancelNotification()
 
     public String UpdateCallBack(String sFileName)
         {
         String sRet = sErrorPrefix + "No file specified";
         String sIP = "";
         String sPort = "";
         int nEnd = 0;
         int nStart = 0;
+        FileInputStream fis = null;
 
         if ((sFileName == null) || (sFileName.length() == 0))
             return(sRet);
 
         Context ctx = contextWrapper.getApplicationContext();
         try {
-            FileInputStream fis = ctx.openFileInput(sFileName);
+            fis = ctx.openFileInput(sFileName);
             int nBytes = fis.available();
             if (nBytes > 0)
                 {
                 byte [] buffer = new byte [nBytes + 1];
                 int nRead = fis.read(buffer, 0, nBytes);
-                fis.close();
                 ctx.deleteFile(sFileName);
                 if (nRead > 0)
                     {
                     String sBuffer = new String(buffer);
                     nEnd = sBuffer.indexOf(',');
                     if (nEnd > 0)
                         {
                         sIP = (sBuffer.substring(0, nEnd)).trim();
@@ -2893,16 +2893,29 @@ private void CancelNotification()
         catch (IOException e)
             {
             sRet = sErrorPrefix + "Couldn't send info to " + sIP + ":" + sPort;
             }
         catch (InterruptedException e)
             {
             e.printStackTrace();
             }
+        finally
+            {
+            if (fis != null)
+                {
+                try {
+                    fis.close();
+                    }
+                catch(IOException e)
+                    {
+                    e.printStackTrace();
+                    }
+                }
+            }
         return(sRet);
         }
 
     public String RegisterTheDevice(String sSrvr, String sPort, String sData)
         {
         String sRet = "";
         String line = "";