Merge pull request #3789 from nextcloud/try-with-resources-in-download-file-operation

operations: properly close FileOutputStream.
This commit is contained in:
Andy Scherzinger 2019-03-27 10:11:23 +01:00 committed by GitHub
commit d4c008188a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -1 +1 @@
474
473

View file

@ -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);
}