Lazily initialize SecureRandom in MimeTypeUtils [SPR-16974] #21512
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
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, wheneverMimeTypeUtils
is loaded, this cost will be incurred, irrespective of whether or notgenerateMultipartBoundary()
is ever called. I think it would be better if theSecureRandom
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:
Referenced from: commits 847202c, 4402336
The text was updated successfully, but these errors were encountered: