Skip to content

Commit ab2410c

Browse files
committed
MimeTypeUtils uses SecureRandom
The prevailing current wisdom is to use the default constructor for secure and let it pick the best algorithm for the OS. On Java 8 (Oracle), Linux this results in "NativePRNG" which uses /dev/random (potentially blocking) for the initial seed, and /dev/urandom (non-blocking) for subsequent calls to nextInt. Issue: SPR-16635
1 parent f6ea740 commit ab2410c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.nio.charset.StandardCharsets;
2020
import java.nio.charset.UnsupportedCharsetException;
21+
import java.security.SecureRandom;
2122
import java.util.ArrayList;
2223
import java.util.Collection;
2324
import java.util.Collections;
@@ -45,7 +46,7 @@ public abstract class MimeTypeUtils {
4546
'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
4647
'V', 'W', 'X', 'Y', 'Z'};
4748

48-
private static final Random RND = new Random();
49+
private static final Random RND = new SecureRandom();
4950

5051
/**
5152
* Comparator used by {@link #sortBySpecificity(List)}.

0 commit comments

Comments
 (0)