Use lambda for ThreadLocal

This commit is contained in:
AsamK 2020-03-23 17:10:11 +01:00
parent e2b7bda65b
commit 0ce64dc923

View file

@ -5,17 +5,14 @@ import java.security.SecureRandom;
public class RandomUtils {
private static final ThreadLocal<SecureRandom> LOCAL_RANDOM = new ThreadLocal<SecureRandom>() {
@Override
protected SecureRandom initialValue() {
private static final ThreadLocal<SecureRandom> LOCAL_RANDOM = ThreadLocal.withInitial(() -> {
SecureRandom rand = getSecureRandomUnseeded();
// Let the SecureRandom seed it self initially
rand.nextBoolean();
return rand;
}
};
});
private static SecureRandom getSecureRandomUnseeded() {
try {