From 4453102e852f4693222d103264c9a62b421f3d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Ostro=C5=BEl=C3=ADk?= Date: Sat, 11 Dec 2021 16:51:27 +0100 Subject: [PATCH 1/2] Polish ExceptionHandlerMethodResolver mapping See gh-27801 --- .../annotation/ExceptionHandlerExceptionResolver.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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..9bb49d0954e 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,7 @@ 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); From 61601de250957b7b2bc4796b99e183ff5e5500d9 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 Dec 2021 15:57:58 +0100 Subject: [PATCH 2/2] Polish formatting See gh-27801 --- .../method/annotation/ExceptionHandlerExceptionResolver.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9bb49d0954e..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,7 +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.computeIfAbsent(handlerType, ExceptionHandlerMethodResolver::new); + ExceptionHandlerMethodResolver resolver = this.exceptionHandlerCache.computeIfAbsent( + handlerType, ExceptionHandlerMethodResolver::new); Method method = resolver.resolveMethod(exception); if (method != null) { return new ServletInvocableHandlerMethod(handlerMethod.getBean(), method, this.applicationContext);