From bac5cd866e3ad685b84be0bcce2bdef573077242 Mon Sep 17 00:00:00 2001 From: Hyunjin Choi Date: Fri, 17 Jan 2020 21:23:45 +0900 Subject: [PATCH] Simplify getSessionAttributesHandler() method --- .../method/annotation/RequestMappingHandlerAdapter.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 7b0f5038ee..ead2f88c8a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -825,11 +825,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter SessionAttributesHandler sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType); if (sessionAttrHandler == null) { synchronized (this.sessionAttributesHandlerCache) { - sessionAttrHandler = this.sessionAttributesHandlerCache.get(handlerType); - if (sessionAttrHandler == null) { - sessionAttrHandler = new SessionAttributesHandler(handlerType, this.sessionAttributeStore); - this.sessionAttributesHandlerCache.put(handlerType, sessionAttrHandler); - } + sessionAttrHandler = this.sessionAttributesHandlerCache.computeIfAbsent(handlerType, type -> new SessionAttributesHandler(type, this.sessionAttributeStore)); } } return sessionAttrHandler;