diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java index 83ae13af4ee..620f4515121 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java @@ -476,11 +476,8 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce // Local exception handler methods on the controller class itself. // To be invoked through the proxy, even in case of an interface-based proxy. handlerType = handlerMethod.getBeanType(); - ExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.get(handlerType); - if (resolver == null) { - resolver = new ExceptionHandlerMethodResolver(handlerType); - this.exceptionHandlerCache.put(handlerType, resolver); - } + ExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.computeIfAbsent( + handlerType, ExceptionHandlerMethodResolver::new); Method method = resolver.resolveMethod(exception); if (method != null) { return new ServletInvocableHandlerMethod(handlerMethod.getBean(), method, this.applicationContext);