You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/10/22 12:53:38 UTC

[commons-crypto] 07/18: Test does not close resource

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit de2cfc30949f14cd04d5dfc46100ed89a5f6ef10
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 22 08:38:46 2023 -0400

    Test does not close resource
---
 .../commons/crypto/stream/PositionedCryptoInputStreamTest.java    | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
index 4ca2c70..77b4672 100644
--- a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
@@ -235,9 +235,11 @@ public class PositionedCryptoInputStreamTest {
     }
 
     private void doReadFullyTests() throws Exception {
-        final PositionedCryptoInputStream in = getCryptoInputStream(0);
-        final String cipherClass = in.getCipher().getClass().getName();
-        doReadFullyTests(cipherClass);
+        try (PositionedCryptoInputStream in = getCryptoInputStream(0);
+                CryptoCipher cipher = in.getCipher()) {
+            final String cipherClass = cipher.getClass().getName();
+            doReadFullyTests(cipherClass);
+        }
     }
 
     private void doReadFullyTests(final String cipherClass) throws Exception {