Cache ServerHttpRequest::getMethod in AbstractServerHttpRequest by yuzawa-san · Pull Request #30139 · spring-projects/spring-framework (original) (raw)
Navigation Menu
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Conversation
ServerHttpRequest.method() is called twice on each HttpMethodPredicate and within CorsUtils.isPreFlightRequest(). Each call has to do a roundtrip all the way into netty and it does a bunch of String hashing to resolve the proper Spring HttpMethod. I moved this work to be done once upon request construction since the field read is cheaper.
Thanks for leaving a PR.
It seems only fair that we introduce the same enhancement for the other ServerHttpRequest implementations, so I moved your changes to AbstractServerHttpRequest.
poutsma changed the title
Cache ServerHttpRequest.method() for Reactor Netty's Requests Cache ServerHttpRequest::method in AbstractServerHttpRequest
poutsma changed the title
Cache ServerHttpRequest::method in AbstractServerHttpRequest Cache ServerHttpRequest::getMethod in AbstractServerHttpRequest
poutsma added a commit that referenced this pull request
- gh-30139: Cache ServerHttpRequest::getMethod in AbstractServerHttpRequest cache reactor request methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})