try-with-resources.

Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/b11f6ffa
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/b11f6ffa
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/b11f6ffa

Branch: refs/heads/master
Commit: b11f6ffaecef327840c3f42b880937a267ac7637
Parents: 9ecfae2
Author: Gary Gregory <ggreg...@apache.org>
Authored: Wed Jun 29 17:08:49 2016 -0700
Committer: Gary Gregory <ggreg...@apache.org>
Committed: Wed Jun 29 17:08:49 2016 -0700

----------------------------------------------------------------------
 .../commons/crypto/cipher/AbstractCipherTest.java   | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/b11f6ffa/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java 
b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java
index 3da0511..65f1472 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java
@@ -82,18 +82,18 @@ public abstract class AbstractCipherTest {
 
     @Test
     public void closeTestAfterInit() throws Exception {
-        CryptoCipher enc = getCipher(transformations[0]);
-        enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
-        enc.close();
+        try (CryptoCipher enc = getCipher(transformations[0])) {
+            enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
+        }
     }
 
     @Test
     public void reInitTest() throws Exception {
-        CryptoCipher enc = getCipher(transformations[0]);
-        enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
-        enc.init(Cipher.DECRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
-        enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
-        enc.close();
+        try (CryptoCipher enc = getCipher(transformations[0])) {
+            enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
+            enc.init(Cipher.DECRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
+            enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new 
IvParameterSpec(IV));
+        }
     }
 
     @Test

Reply via email to