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:
Rossen Stoyanchev
2020-02-03 20:59:30 +00:00
parent bac5cd866e
commit e7d40f930f

View File

@@ -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));
}
/**