Skip to content

Commit e7d40f9

Browse files
committed
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
1 parent bac5cd8 commit e7d40f9

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,9 @@ protected long getLastModifiedInternal(HttpServletRequest request, HandlerMethod
821821
* (never {@code null}).
822822
*/
823823
private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) {
824-
Class<?> handlerType = handlerMethod.getBeanType();
825-
SessionAttributesHandler sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType);
826-
if (sessionAttrHandler == null) {
827-
synchronized (this.sessionAttributesHandlerCache) {
828-
sessionAttrHandler = this.sessionAttributesHandlerCache.computeIfAbsent(handlerType, type -> new SessionAttributesHandler(type, this.sessionAttributeStore));
829-
}
830-
}
831-
return sessionAttrHandler;
824+
return this.sessionAttributesHandlerCache.computeIfAbsent(
825+
handlerMethod.getBeanType(),
826+
type -> new SessionAttributesHandler(type, this.sessionAttributeStore));
832827
}
833828

834829
/**

0 commit comments

Comments
 (0)