Remove synchronized block
As per the Javadoc of ConcurrentHashMap its computeIfAbsent implementation is atomic and hence already synchronized internally, so we can remove the surrounding synchronization block. See gh-24470
This commit is contained in:
@@ -821,14 +821,9 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
* (never {@code null}).
|
||||
*/
|
||||
private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) {
|
||||
Class<?> handlerType = handlerMethod.getBeanType();
|
||||
SessionAttributesHandler sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType);
|
||||
if (sessionAttrHandler == null) {
|
||||
synchronized (this.sessionAttributesHandlerCache) {
|
||||
sessionAttrHandler = this.sessionAttributesHandlerCache.computeIfAbsent(handlerType, type -> new SessionAttributesHandler(type, this.sessionAttributeStore));
|
||||
}
|
||||
}
|
||||
return sessionAttrHandler;
|
||||
return this.sessionAttributesHandlerCache.computeIfAbsent(
|
||||
handlerMethod.getBeanType(),
|
||||
type -> new SessionAttributesHandler(type, this.sessionAttributeStore));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user