diff --git a/src/main/java/name/neuhalfen/projects/crypto/bouncycastle/openpgp/decrypting/DecryptionStreamFactory.java b/src/main/java/name/neuhalfen/projects/crypto/bouncycastle/openpgp/decrypting/DecryptionStreamFactory.java index b3bcd8a..161cd93 100644 --- a/src/main/java/name/neuhalfen/projects/crypto/bouncycastle/openpgp/decrypting/DecryptionStreamFactory.java +++ b/src/main/java/name/neuhalfen/projects/crypto/bouncycastle/openpgp/decrypting/DecryptionStreamFactory.java @@ -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(