aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-11-14 10:30:59 +0000
committerPJ Fanning <fanningpj@apache.org>2021-11-14 10:30:59 +0000
commit2ebe1aa650c45eed7b7c8a918c99abd0e24b7317 (patch)
treec7937574c355fea814df63682225395f52e965b9 /poi/src
parent8365ee1611c87346277854f3333d3c5f3668e7b9 (diff)
downloadpoi-2ebe1aa650c45eed7b7c8a918c99abd0e24b7317.tar.gz
poi-2ebe1aa650c45eed7b7c8a918c99abd0e24b7317.zip
[github-278] Resolve all SpotBugs P1 issues in Main and Test. Thanks to Andreas Reichel. This closes #278
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895017 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r--poi/src/main/java/org/apache/poi/util/RandomSingleton.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/poi/src/main/java/org/apache/poi/util/RandomSingleton.java b/poi/src/main/java/org/apache/poi/util/RandomSingleton.java
new file mode 100644
index 0000000000..b6b9f59ba8
--- /dev/null
+++ b/poi/src/main/java/org/apache/poi/util/RandomSingleton.java
@@ -0,0 +1,19 @@
+package org.apache.poi.util;
+
+import java.security.SecureRandom;
+
+/*
+If it is important that the generated Random numbers not be guessable,
+you MUST NOT create a new Random for each random number; the values are too easily guessable.
+
+You should strongly consider using a java.security.SecureRandom instead
+(and avoid allocating a new SecureRandom for each random number needed).
+*/
+
+public class RandomSingleton {
+ private static final SecureRandom INSTANCE = new SecureRandom();
+
+ public static SecureRandom getInstance() {
+ return INSTANCE;
+ }
+}