Bug 1251213 - release resources from fis. r?sebastian
MozReview-Commit-ID: 9RTJprP6rh2
--- 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 = "";