Browse Source

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
pull/24476/head
Rossen Stoyanchev 5 years ago
parent
commit
e7d40f930f
  1. 11
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java

11
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java

@ -821,14 +821,9 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
* (never {@code null}). * (never {@code null}).
*/ */
private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) { private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) {
Class<?> handlerType = handlerMethod.getBeanType(); return this.sessionAttributesHandlerCache.computeIfAbsent(
SessionAttributesHandler sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType); handlerMethod.getBeanType(),
if (sessionAttrHandler == null) { type -> new SessionAttributesHandler(type, this.sessionAttributeStore));
synchronized (this.sessionAttributesHandlerCache) {
sessionAttrHandler = this.sessionAttributesHandlerCache.computeIfAbsent(handlerType, type -> new SessionAttributesHandler(type, this.sessionAttributeStore));
}
}
return sessionAttrHandler;
} }
/** /**

Loading…
Cancel
Save