summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2010-04-29 16:14:52 -0700
committerAndroid Code Review <code-review@android.com>2010-04-29 16:14:52 -0700
commit2ceb570ad3b37fca2169ea9f453984cebf8c372c (patch)
tree751a9fbf83f0d615f1c9a6fc904f1a250310e146 /src/com/android
parentbdf3f6c3b8c456bcc8a1c94b6cd4c0f043bcc5cc (diff)
parent3755040b84970071e07ccfa1e90f76c1bc3b119c (diff)
downloadpackages_apps_Browser-2ceb570ad3b37fca2169ea9f453984cebf8c372c.zip
packages_apps_Browser-2ceb570ad3b37fca2169ea9f453984cebf8c372c.tar.gz
packages_apps_Browser-2ceb570ad3b37fca2169ea9f453984cebf8c372c.tar.bz2
Merge "Fixed FindBugs warnings in BrowserBackupAgent.java"
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/browser/BrowserBackupAgent.java57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/com/android/browser/BrowserBackupAgent.java b/src/com/android/browser/BrowserBackupAgent.java
index 387555d..84672b1 100644
--- a/src/com/android/browser/BrowserBackupAgent.java
+++ b/src/com/android/browser/BrowserBackupAgent.java
@@ -84,6 +84,10 @@ public class BrowserBackupAgent extends BackupAgent {
savedVersion = in.readInt();
} catch (EOFException e) {
// It means we had no previous state; that's fine
+ } finally {
+ if (in != null) {
+ in.close();
+ }
}
// Build a flattened representation of the bookmarks table
@@ -174,6 +178,10 @@ public class BrowserBackupAgent extends BackupAgent {
} catch (IOException ioe) {
Log.w(TAG, "Bad backup data; not restoring");
crc = -1;
+ } finally {
+ if (in != null) {
+ in.close();
+ }
}
}
@@ -187,7 +195,7 @@ public class BrowserBackupAgent extends BackupAgent {
}
}
- class Bookmark {
+ static class Bookmark {
public String url;
public int visits;
public long date;
@@ -258,13 +266,18 @@ public class BrowserBackupAgent extends BackupAgent {
data.writeEntityHeader(key, toCopy);
FileInputStream in = new FileInputStream(file);
- int nRead;
- while (toCopy > 0) {
- nRead = in.read(buf, 0, CHUNK);
- data.writeEntityData(buf, nRead);
- toCopy -= nRead;
+ try {
+ int nRead;
+ while (toCopy > 0) {
+ nRead = in.read(buf, 0, CHUNK);
+ data.writeEntityData(buf, nRead);
+ toCopy -= nRead;
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
}
- in.close();
}
// Read the given file from backup to a file, calculating a CRC32 along the way
@@ -275,14 +288,18 @@ public class BrowserBackupAgent extends BackupAgent {
CRC32 crc = new CRC32();
FileOutputStream out = new FileOutputStream(file);
- while (toRead > 0) {
- int numRead = data.readEntityData(buf, 0, CHUNK);
- crc.update(buf, 0, numRead);
- out.write(buf, 0, numRead);
- toRead -= numRead;
+ try {
+ while (toRead > 0) {
+ int numRead = data.readEntityData(buf, 0, CHUNK);
+ crc.update(buf, 0, numRead);
+ out.write(buf, 0, numRead);
+ toRead -= numRead;
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ }
}
-
- out.close();
return crc.getValue();
}
@@ -291,8 +308,14 @@ public class BrowserBackupAgent extends BackupAgent {
throws IOException {
DataOutputStream out = new DataOutputStream(
new FileOutputStream(stateFile.getFileDescriptor()));
- out.writeLong(fileSize);
- out.writeLong(crc);
- out.writeInt(BACKUP_AGENT_VERSION);
+ try {
+ out.writeLong(fileSize);
+ out.writeLong(crc);
+ out.writeInt(BACKUP_AGENT_VERSION);
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
}
}