Polishing

This commit is contained in:
Sam Brannen
2023-08-05 10:49:39 +03:00
parent 14911fb32f
commit 59b78cc513
2 changed files with 18 additions and 9 deletions

View File

@@ -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