提交 32d4d283 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

SecureRandom is already synchronized

上级 5c6935dd
...@@ -260,10 +260,7 @@ public class MathUtils { ...@@ -260,10 +260,7 @@ public class MathUtils {
* @return the random long value * @return the random long value
*/ */
public static long secureRandomLong() { public static long secureRandomLong() {
SecureRandom sr = getSecureRandom(); return getSecureRandom().nextLong();
synchronized (sr) {
return sr.nextLong();
}
} }
/** /**
...@@ -286,10 +283,7 @@ public class MathUtils { ...@@ -286,10 +283,7 @@ public class MathUtils {
len = 1; len = 1;
} }
byte[] buff = new byte[len]; byte[] buff = new byte[len];
SecureRandom sr = getSecureRandom(); getSecureRandom().nextBytes(buff);
synchronized (sr) {
sr.nextBytes(buff);
}
return buff; return buff;
} }
...@@ -312,10 +306,7 @@ public class MathUtils { ...@@ -312,10 +306,7 @@ public class MathUtils {
* @return the random long value * @return the random long value
*/ */
public static int secureRandomInt(int lowerThan) { public static int secureRandomInt(int lowerThan) {
SecureRandom sr = getSecureRandom(); return getSecureRandom().nextInt(lowerThan);
synchronized (sr) {
return sr.nextInt(lowerThan);
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论