Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Revert "refactor: use Closeable#use extension where applicable"
Browse files Browse the repository at this point in the history
This reverts commit 69513bf.
  • Loading branch information
msfjarvis committed Sep 26, 2024
1 parent cb22561 commit 04f4b98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ class PasswordExportService : Service() {
val destOutputStream = contentResolver.openOutputStream(targetPasswordFile.uri)

if (destOutputStream != null && sourceInputStream != null) {
sourceInputStream.use { source -> destOutputStream.use { dest -> source.copyTo(dest) } }
sourceInputStream.copyTo(destOutputStream, 1024)

sourceInputStream.close()
destOutputStream.close()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public class PGPainlessCryptoHandler @Inject constructor() :
.addDecryptionKeys(keyringCollection, protector)
.addDecryptionPassphrase(Passphrase.fromPassword(passphrase))
)
decryptionStream.use { Streams.pipeAll(it, outputStream) }
Streams.pipeAll(decryptionStream, outputStream)
decryptionStream.close()
return@runCatching
}
.mapError { error ->
Expand Down Expand Up @@ -120,7 +121,8 @@ public class PGPainlessCryptoHandler @Inject constructor() :
.setAsciiArmor(options.isOptionEnabled(PGPEncryptOptions.ASCII_ARMOR))
val encryptionStream =
PGPainless.encryptAndOrSign().onOutputStream(outputStream).withOptions(producerOptions)
encryptionStream.use { Streams.pipeAll(plaintextStream, it) }
Streams.pipeAll(plaintextStream, encryptionStream)
encryptionStream.close()
val result = encryptionStream.result
publicKeyRingCollection.forEach { keyRing ->
require(result.isEncryptedFor(keyRing)) {
Expand Down

0 comments on commit 04f4b98

Please sign in to comment.