Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions