Performance enhancement in execution of ResponseEntity.of() #25183
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Hi Team,
I think I have found a very small performance enhancement when using ResponseEntity.of
Currently the code for the method is
That is the NOT_FOUND Response Entity is always built, even if it is not required.
The small change would be
By using the orElseGet method, the construction of the NOT_FOUND Response Entity is delayed until it is required.
There maybe other considerations here, such as the construction of the lambda needs to be balanced against the construction of the NOT_FOUND Response Entity.
In your estimation, is a PR worthwhile for this small enhancement?
Cheers,
Brett
The text was updated successfully, but these errors were encountered: