Skip to content

Lazily initialize SecureRandom in MimeTypeUtils [SPR-16974] #21512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jun 25, 2018 · 0 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 25, 2018

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:

Referenced from: commits 847202c, 4402336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants