diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java index e4562a16c2..e53c8c0ef0 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java @@ -61,6 +61,11 @@ import org.springframework.web.service.annotation.HttpExchange; public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMapping implements EmbeddedValueResolverAware { + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + private static final RequestMethod[] EMPTY_REQUEST_METHOD_ARRAY = new RequestMethod[0]; + + private final Map>> pathPrefixes = new LinkedHashMap<>(); private RequestedContentTypeResolver contentTypeResolver = new RequestedContentTypeResolverBuilder().build(); @@ -178,12 +183,12 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi getCustomTypeCondition(clazz) : getCustomMethodCondition((Method) element)); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class); - if (requestMapping != null){ + if (requestMapping != null) { return createRequestMappingInfo(requestMapping, customCondition); } HttpExchange httpExchange = AnnotatedElementUtils.findMergedAnnotation(element, HttpExchange.class); - if (httpExchange != null){ + if (httpExchange != null) { return createRequestMappingInfo(httpExchange, customCondition); } @@ -294,12 +299,12 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi } private static String[] toStringArray(String value) { - return StringUtils.hasText(value) ? new String[] {value} : new String[] {}; + return (StringUtils.hasText(value) ? new String[] {value} : EMPTY_STRING_ARRAY); } private static RequestMethod[] toMethodArray(String method) { return (StringUtils.hasText(method) ? - new RequestMethod[] {RequestMethod.valueOf(method)} : new RequestMethod[] {}); + new RequestMethod[] {RequestMethod.valueOf(method)} : EMPTY_REQUEST_METHOD_ARRAY); } @Override diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 3924be9bcd..456e3f1fc3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -79,6 +79,11 @@ import org.springframework.web.util.pattern.PathPatternParser; public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMapping implements MatchableHandlerMapping, EmbeddedValueResolverAware { + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + private static final RequestMethod[] EMPTY_REQUEST_METHOD_ARRAY = new RequestMethod[0]; + + private boolean defaultPatternParser = true; private boolean useSuffixPatternMatch = false; @@ -339,12 +344,12 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi getCustomTypeCondition(clazz) : getCustomMethodCondition((Method) element)); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class); - if(requestMapping != null){ + if (requestMapping != null) { return createRequestMappingInfo(requestMapping, customCondition); } HttpExchange httpExchange = AnnotatedElementUtils.findMergedAnnotation(element, HttpExchange.class); - if(httpExchange != null){ + if (httpExchange != null) { return createRequestMappingInfo(httpExchange, customCondition); } @@ -448,14 +453,13 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi } } - private static String[] toStringArray(String value) { - return (StringUtils.hasText(value) ? new String[] {value} : new String[] {}); + return (StringUtils.hasText(value) ? new String[] {value} : EMPTY_STRING_ARRAY); } private static RequestMethod[] toMethodArray(String method) { return (StringUtils.hasText(method) ? - new RequestMethod[] {RequestMethod.valueOf(method)} : new RequestMethod[] {}); + new RequestMethod[] {RequestMethod.valueOf(method)} : EMPTY_REQUEST_METHOD_ARRAY); } @Override