From 641303baffd902cbde56b4cc580153e46331be20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Ostro=C5=BEl=C3=ADk?= Date: Mon, 26 Sep 2022 18:00:02 +0200 Subject: [PATCH] Remove unnecessary sync block in ControllerMethodResolver Closes gh-29208 --- .../method/annotation/ControllerMethodResolver.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java index 70e6aa8549..e8ff100c45 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java @@ -372,17 +372,7 @@ class ControllerMethodResolver { */ public SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) { Class handlerType = handlerMethod.getBeanType(); - SessionAttributesHandler result = this.sessionAttributesHandlerCache.get(handlerType); - if (result == null) { - synchronized (this.sessionAttributesHandlerCache) { - result = this.sessionAttributesHandlerCache.get(handlerType); - if (result == null) { - result = new SessionAttributesHandler(handlerType); - this.sessionAttributesHandlerCache.put(handlerType, result); - } - } - } - return result; + return this.sessionAttributesHandlerCache.computeIfAbsent(handlerType, SessionAttributesHandler::new); } }