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 2022/12/11 23:34:39 UTC
[commons-crypto] branch master updated: Make instance variable final
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
The following commit(s) were added to refs/heads/master by this push:
new 8391625 Make instance variable final
8391625 is described below
commit 8391625ee3dc5734695f19a1649652499b8d54b9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Dec 11 18:34:34 2022 -0500
Make instance variable final
---
.../commons/crypto/random/JavaCryptoRandom.java | 24 +++++++++++-----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java
index 13e2538..627532e 100644
--- a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java
+++ b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java
@@ -26,6 +26,10 @@ import org.apache.commons.crypto.utils.Utils;
/**
* A CryptoRandom of Java implementation.
+ * <p>
+ * N.B. this class is not public/protected so does not appear in the main Javadoc Please ensure that property use is documented in the enum
+ * CryptoRandomFactory.RandomProvider
+ * </p>
*/
class JavaCryptoRandom extends Random implements CryptoRandom {
@@ -34,7 +38,7 @@ class JavaCryptoRandom extends Random implements CryptoRandom {
*/
private static final long serialVersionUID = 5517475898166660050L;
- private SecureRandom instance;
+ private final SecureRandom instance;
/**
* Constructs a {@link JavaCryptoRandom}.
@@ -44,18 +48,14 @@ class JavaCryptoRandom extends Random implements CryptoRandom {
* to get the name of the algorithm, with a default of
* {@link CryptoRandomFactory#JAVA_ALGORITHM_DEFAULT}
*/
- // N.B. this class is not public/protected so does not appear in the main Javadoc
- // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider
public JavaCryptoRandom(final Properties properties) {
- try {
- instance = SecureRandom
- .getInstance(properties
- .getProperty(
- CryptoRandomFactory.JAVA_ALGORITHM_KEY,
- CryptoRandomFactory.JAVA_ALGORITHM_DEFAULT));
- } catch (final NoSuchAlgorithmException e) {
- instance = new SecureRandom();
- }
+ SecureRandom tmp;
+ try {
+ tmp = SecureRandom.getInstance(properties.getProperty(CryptoRandomFactory.JAVA_ALGORITHM_KEY, CryptoRandomFactory.JAVA_ALGORITHM_DEFAULT));
+ } catch (final NoSuchAlgorithmException e) {
+ tmp = new SecureRandom();
+ }
+ instance = tmp;
}
/**