Ensure backup schedule file is closed.

Change-Id: Ie4a62cda74815c67c62fb08e8df25a71d6102d4c
This commit is contained in:
Michael Wright
2014-07-29 18:28:47 -07:00
parent 40b8ef99a5
commit 46db93404b

View File

@@ -1266,10 +1266,13 @@ public class BackupManagerService extends IBackupManager.Stub {
ArrayList<FullBackupEntry> schedule = null;
synchronized (mQueueLock) {
if (mFullBackupScheduleFile.exists()) {
FileInputStream fstream = null;
BufferedInputStream bufStream = null;
DataInputStream in = null;
try {
FileInputStream fstream = new FileInputStream(mFullBackupScheduleFile);
BufferedInputStream bufStream = new BufferedInputStream(fstream);
DataInputStream in = new DataInputStream(bufStream);
fstream = new FileInputStream(mFullBackupScheduleFile);
bufStream = new BufferedInputStream(fstream);
in = new DataInputStream(bufStream);
int version = in.readInt();
if (version != SCHEDULE_FILE_VERSION) {
@@ -1289,6 +1292,10 @@ public class BackupManagerService extends IBackupManager.Stub {
Slog.e(TAG, "Unable to read backup schedule", e);
mFullBackupScheduleFile.delete();
schedule = null;
} finally {
IoUtils.closeQuietly(in);
IoUtils.closeQuietly(bufStream);
IoUtils.closeQuietly(fstream);
}
}