From c59b41d7612271cb7322290fe8ffced36bd8cc1d Mon Sep 17 00:00:00 2001 From: ardevd Date: Tue, 26 Mar 2019 12:12:16 +0100 Subject: [PATCH] operations: properly close FileOutputStream. Classes that implement the Closeable interface or its super-interface, AutoCloseable, needs to be closed after use. try-with-resources does this for you automatically. Signed-off-by: ardevd Signed-off-by: nextcloud-android-bot Signed-off-by: tobiasKaminsky --- scripts/analysis/findbugs-results.txt | 2 +- .../owncloud/android/operations/DownloadFileOperation.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 6a5426c9b3..0642336574 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -474 \ No newline at end of file +473 \ No newline at end of file diff --git a/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java b/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java index fd0bc756bd..859c4acad3 100644 --- a/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java +++ b/src/main/java/com/owncloud/android/operations/DownloadFileOperation.java @@ -203,8 +203,9 @@ public class DownloadFileOperation extends RemoteOperation { try { byte[] decryptedBytes = EncryptionUtils.decryptFile(tmpFile, key, iv, authenticationTag); - FileOutputStream fileOutputStream = new FileOutputStream(tmpFile); - fileOutputStream.write(decryptedBytes); + try (FileOutputStream fileOutputStream = new FileOutputStream(tmpFile)) { + fileOutputStream.write(decryptedBytes); + } } catch (Exception e) { return new RemoteOperationResult(e); }