Unverified 提交 1f64833c authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #714 from katzyn/MathUtils

SecureRandom is already synchronized
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论