Skip to content

Commit

Permalink
Merge branch 'issue-46' of https://github.com/ispringer/bouncy-gpg in…
Browse files Browse the repository at this point in the history
…to ispringer-issue-46

* 'issue-46' of https://github.com/ispringer/bouncy-gpg:
  fixes #46 by reverting 012c3f9; that commit did not make sense, as we should not close a stream that is going to be wrapped by additional streams, which haven't even been created yet; instead the wrapping streams should be responsible for closing the streams they wrap once they are fully done with them; all tests pass
  • Loading branch information
neuhalje committed Jul 12, 2020
2 parents 1ab3b17 + 84f2e64 commit 59dcae1
Showing 1 changed file with 5 additions and 12 deletions.
Expand Up @@ -157,18 +157,11 @@ private InputStream nextDecryptedStream(PGPObjectFactory factory,


// decrypt the data

try(
InputStream plainText = pbe
.getDataStream(new BcPublicKeyDataDecryptorFactory(
privateKey)) // NOPMD: AvoidInstantiatingObjectsInLoops
)
{

final PGPObjectFactory nextFactory = new PGPObjectFactory(plainText,
new BcKeyFingerprintCalculator());// NOPMD: AvoidInstantiatingObjectsInLoops
return nextDecryptedStream(nextFactory, state); // NOPMD: OnlyOneReturn
}
final InputStream plainText = pbe // NOPMD: CloseResource
.getDataStream(new BcPublicKeyDataDecryptorFactory(privateKey)); // NOPMD: AvoidInstantiatingObjectsInLoops
final PGPObjectFactory nextFactory = new PGPObjectFactory(plainText,
new BcKeyFingerprintCalculator());// NOPMD: AvoidInstantiatingObjectsInLoops
return nextDecryptedStream(nextFactory, state); // NOPMD: OnlyOneReturn
} else if (pgpObj instanceof PGPCompressedData) {
LOGGER.trace("Found instance of PGPCompressedData");
final PGPObjectFactory nextFactory = new PGPObjectFactory(
Expand Down

0 comments on commit 59dcae1

Please sign in to comment.