diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/Utils.java b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/Utils.java index 0cec6f5138c9..5047a528d234 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/Utils.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/Utils.java @@ -31,7 +31,6 @@ import org.mozilla.apache.commons.codec.binary.Base64; import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.nativecode.NativeCrypto; import org.mozilla.gecko.sync.setup.Constants; -import org.mozilla.gecko.util.IOUtils; import org.mozilla.gecko.util.StringUtils; import android.content.Context; @@ -489,10 +488,14 @@ public class Utils { throw new IllegalArgumentException("Passed null filename in readFile."); } + FileInputStream fis = null; + InputStreamReader isr = null; BufferedReader br = null; try { - br = new BufferedReader(new InputStreamReader(context.openFileInput(filename), StringUtils.UTF_8)); + fis = context.openFileInput(filename); + isr = new InputStreamReader(fis, StringUtils.UTF_8); + br = new BufferedReader(isr); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { @@ -502,7 +505,20 @@ public class Utils { } catch (Exception e) { return null; } finally { - IOUtils.safeStreamClose(br); + if (isr != null) { + try { + isr.close(); + } catch (IOException e) { + // Ignore. + } + } + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + // Ignore. + } + } } } diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/net/MozResponse.java b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/net/MozResponse.java index da389fe539ab..3792abbeda8c 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/net/MozResponse.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/net/MozResponse.java @@ -18,7 +18,6 @@ import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.sync.ExtendedJSONObject; import org.mozilla.gecko.sync.NonArrayJSONException; import org.mozilla.gecko.sync.NonObjectJSONException; -import org.mozilla.gecko.util.IOUtils; import org.mozilla.gecko.util.StringUtils; import ch.boye.httpclientandroidlib.Header; @@ -107,12 +106,12 @@ public class MozResponse { throw new IOException("no entity"); } - Reader in = null; + InputStream content = entity.getContent(); try { - in = new BufferedReader(new InputStreamReader(entity.getContent(), StringUtils.UTF_8)); + Reader in = new BufferedReader(new InputStreamReader(content, "UTF-8")); return new ExtendedJSONObject(in); } finally { - IOUtils.safeStreamClose(in); + content.close(); } }