Closed
Description
Andy Wilkinson opened SPR-16974 and commented
Creating a new instance of SecureRandom
can have a large cost in terms of elapsed time. On Linux, the JVM uses /dev/random
by default which will block until there is sufficient entropy available to produce a random value. As things stand, whenever MimeTypeUtils
is loaded, this cost will be incurred, irrespective of whether or not generateMultipartBoundary()
is ever called. I think it would be better if the SecureRandom
instance was initialized lazily so that the cost is only incurred when the instance is needed.
Affects: 5.0.7
Reference URL: spring-projects/spring-boot#6174
Issue Links:
- Generate multipart boundary using SecureRandom [SPR-16635] #21176 Generate multipart boundary using SecureRandom