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

Commit 19661358 authored by lijilou's avatar lijilou
Browse files

ensure the opend resources are eventually closed when IOException happen.

Bug: none
Flag: EXEMPT minor optimization
Change-Id: Ie4d86cc88de765cdb42270de44fa61cfb04c88d2
parent deab34dc
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -354,10 +354,8 @@ class SnapshotPersistQueue {
            bitmap.recycle();

            final File file = mPersistInfoProvider.getHighResolutionBitmapFile(mId, mUserId);
            try {
                FileOutputStream fos = new FileOutputStream(file);
            try (FileOutputStream fos = new FileOutputStream(file)) {
                swBitmap.compress(JPEG, COMPRESS_QUALITY, fos);
                fos.close();
            } catch (IOException e) {
                Slog.e(TAG, "Unable to open " + file + " for persisting.", e);
                return false;
@@ -375,10 +373,8 @@ class SnapshotPersistQueue {
            swBitmap.recycle();

            final File lowResFile = mPersistInfoProvider.getLowResolutionBitmapFile(mId, mUserId);
            try {
                FileOutputStream lowResFos = new FileOutputStream(lowResFile);
            try (FileOutputStream lowResFos = new FileOutputStream(lowResFile)) {
                lowResBitmap.compress(JPEG, COMPRESS_QUALITY, lowResFos);
                lowResFos.close();
            } catch (IOException e) {
                Slog.e(TAG, "Unable to open " + lowResFile + " for persisting.", e);
                return false;