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

Commit 0284d810 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "PowerStatsLogger: ensure the opend stream is closed when IOException happen." into main

parents 9e5a9cae 35896935
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -285,14 +285,20 @@ public final class PowerStatsLogger extends Handler {
    }

    private void updateCacheFile(String cacheFilename, byte[] data) {
        AtomicFile atomicCachedFile = null;
        FileOutputStream fos = null;
        try {
            final AtomicFile atomicCachedFile =
            atomicCachedFile =
                    new AtomicFile(new File(mDataStoragePath, cacheFilename));
            final FileOutputStream fos = atomicCachedFile.startWrite();
            fos = atomicCachedFile.startWrite();
            fos.write(data);
            atomicCachedFile.finishWrite(fos);
        } catch (IOException e) {
            Slog.e(TAG, "Failed to write current data to cached file", e);
            if (fos != null) {
                atomicCachedFile.failWrite(fos);
            }
            return;
        }
    }