Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c083c8b authored by Jing Ji's avatar Jing Ji
Browse files

Finish the GZIPOutputStream after copying the data into it

...while adding compressed entries to the dropbox.

Bug: 177907504
Test: atest CtsDropBoxManagerTestCases
Test: atest FrameworksServicesTests:com.android.server.DropBoxTest
Test: atest CtsAppExitTestCases:ActivityManagerAppExitInfoTest#testAnr
Change-Id: I56378593295bce646b4a4103bc6ade5e4d507f32
parent 805b216f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.SortedSet;
@@ -446,7 +445,10 @@ public final class DropBoxManagerService extends SystemService {
            // from an in-memory buffer, or another file on disk; if we buffered
            // we'd lose out on sendfile() optimizations
            if (forceCompress) {
                FileUtils.copy(in, new GZIPOutputStream(new FileOutputStream(fd)));
                final GZIPOutputStream gzipOutputStream =
                        new GZIPOutputStream(new FileOutputStream(fd));
                FileUtils.copy(in, gzipOutputStream);
                gzipOutputStream.finish();
            } else {
                FileUtils.copy(in, new FileOutputStream(fd));
            }