You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/05/10 22:21:59 UTC
[isis] branch 2112_SpringBoot updated: ISIS-2117: don't use shared
random instances
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch 2112_SpringBoot
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/2112_SpringBoot by this push:
new 400e0ee ISIS-2117: don't use shared random instances
400e0ee is described below
commit 400e0eeac9199dded6c8ec00661ee566173355b0
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat May 11 00:21:51 2019 +0200
ISIS-2117: don't use shared random instances
- basically to improve performance in multithreaded contexts
---
.../authentication/standard/RandomCodeGenerator10Chars.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/core/security/src/main/java/org/apache/isis/core/security/authentication/standard/RandomCodeGenerator10Chars.java b/core/security/src/main/java/org/apache/isis/core/security/authentication/standard/RandomCodeGenerator10Chars.java
index ea5a991..8299c69 100644
--- a/core/security/src/main/java/org/apache/isis/core/security/authentication/standard/RandomCodeGenerator10Chars.java
+++ b/core/security/src/main/java/org/apache/isis/core/security/authentication/standard/RandomCodeGenerator10Chars.java
@@ -16,19 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.isis.core.security.authentication.standard;
+import java.util.Random;
+
public class RandomCodeGenerator10Chars implements RandomCodeGenerator {
private static final int NUMBER_CHARACTERS = 10;
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ private final Random random = new Random();
+
@Override
public String generateRandomCode() {
final StringBuilder buf = new StringBuilder(NUMBER_CHARACTERS);
for (int i = 0; i < NUMBER_CHARACTERS; i++) {
- final int pos = (int) ((Math.random() * CHARACTERS.length()));
+ final int pos = random.nextInt(CHARACTERS.length());
buf.append(CHARACTERS.charAt(pos));
}
return buf.toString();