You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by sd...@apache.org on 2016/07/22 07:00:37 UTC

[09/50] commons-crypto git commit: Use try-with-resources.

Use 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/6f6d6b0c
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/6f6d6b0c
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/6f6d6b0c

Branch: refs/heads/CRYPTO-1.0.0
Commit: 6f6d6b0c9c6cf3d9c991c7e50a5671210b4a74e3
Parents: 9e83ff3
Author: ggregory <gg...@apache.org>
Authored: Fri Jul 8 09:19:01 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jul 8 09:19:01 2016 -0700

----------------------------------------------------------------------
 .../crypto/random/AbstractRandomTest.java       | 38 ++++++++++----------
 1 file changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/6f6d6b0c/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java b/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java
index 1d49bc4..619c1a3 100644
--- a/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java
@@ -47,29 +47,29 @@ public abstract class AbstractRandomTest {
     @Test(timeout = 120000)
     public void testRandomBytesMultiThreaded() throws Exception {
         final int threadCount = 100;
-        final CryptoRandom random = getCryptoRandom();
-        final List<Thread> threads = new ArrayList<>(threadCount);
+        try (final CryptoRandom random = getCryptoRandom()) {
+            final List<Thread> threads = new ArrayList<>(threadCount);
 
-        for (int i = 0; i < threadCount; i++) {
-            Thread t = new Thread(new Runnable() {
-                @Override
-                public void run() {
-                    checkRandomBytes(random, 10);
-                    checkRandomBytes(random, 1000);
-                    checkRandomBytes(random, 100000);
-                }
-            });
-            t.start();
-            threads.add(t);
-        }
+            for (int i = 0; i < threadCount; i++) {
+                Thread t = new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        checkRandomBytes(random, 10);
+                        checkRandomBytes(random, 1000);
+                        checkRandomBytes(random, 100000);
+                    }
+                });
+                t.start();
+                threads.add(t);
+            }
 
-        for (Thread t : threads) {
-            if (!t.getState().equals(State.NEW)) {
-                t.join();
+            for (Thread t : threads) {
+                if (!t.getState().equals(State.NEW)) {
+                    t.join();
+                }
             }
-        }
 
-        random.close();
+        }
     }
 
     /**