From 59397a8e055faa0e2ed05b20785e43c03db86a1a Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Wed, 6 Jul 2016 15:10:01 -0700 Subject: [PATCH] Explicitly flush compress/encrypt stream before close We're losing the stream footer for mysterious reasons; maybe this will help even though supposedly close() is expected to flush pending buffered writes anyway. In particular, an explicit flush of the compression stage will generate a SYNC_FLUSH point, which ordinary deflate-at-close operation does not. Bug 28056941 Change-Id: I96580411257932d7addb176c6672eae72a5ac6f7 --- .../java/com/android/server/backup/BackupManagerService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 1c87dc3079642..edcc7486fbbf8 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -4315,7 +4315,10 @@ public class BackupManagerService { Slog.e(TAG, "Internal exception during full backup", e); } finally { try { - if (out != null) out.close(); + if (out != null) { + out.flush(); + out.close(); + } mOutputFile.close(); } catch (IOException e) { /* nothing we can do about this */