فهرست منبع

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 <edvard.holst@gmail.com>
Signed-off-by: nextcloud-android-bot <android@nextcloud.com>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
ardevd 6 سال پیش
والد
کامیت
c59b41d761

+ 1 - 1
scripts/analysis/findbugs-results.txt

@@ -1 +1 @@
-474
+473

+ 3 - 2
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);
                 }