Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1032)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/WebappAuthenticator.java

Issue 405403002: Close FileOutputStream in finally block in WebAppAuthenticator class method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/WebappAuthenticator.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/WebappAuthenticator.java b/chrome/android/java/src/org/chromium/chrome/browser/WebappAuthenticator.java
index 8a3f4f2fa83019825c6e5d5d045e76ad871fd54d..f71fa671af9a248a3922d71804a68bebeea65b90 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/WebappAuthenticator.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/WebappAuthenticator.java
@@ -115,7 +115,7 @@ public class WebappAuthenticator {
if (input != null) {
input.close();
}
- } catch (Exception e) {
+ } catch (IOException e) {
Log.e(TAG, "Could not close key input stream '" + file + "': " + e);
}
}
@@ -124,6 +124,7 @@ public class WebappAuthenticator {
private static boolean writeKeyToFile(Context context, String basename, SecretKey key) {
File file = context.getFileStreamPath(basename);
byte[] keyBytes = key.getEncoded();
+ FileOutputStream output = null;
if (MAC_KEY_BYTE_COUNT != keyBytes.length) {
Log.e(TAG, "writeKeyToFile got key encoded bytes length " + keyBytes.length +
"; expected " + MAC_KEY_BYTE_COUNT);
@@ -131,13 +132,20 @@ public class WebappAuthenticator {
}
try {
- FileOutputStream output = new FileOutputStream(file);
+ output = new FileOutputStream(file);
output.write(keyBytes);
- output.close();
return true;
} catch (Exception e) {
Log.e(TAG, "Could not write key to '" + file + "': " + e);
return false;
+ } finally {
+ try {
+ if (output != null) {
+ output.close();
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "Could not close key output stream '" + file + "': " + e);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698