diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 43a63e5c4da..9dfdf262e07 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -124,7 +124,8 @@ public class RequestMappingHandlerMapping extends AbstractHandlerMethodMapping patterns; - private final Set methods; + private final RequestMethodsRequestCondition methodsCondition; private final ParamsRequestCondition paramsCondition; @@ -62,20 +64,20 @@ public final class RequestMappingInfo { * *

Package protected for testing purposes. */ - RequestMappingInfo(Collection patterns, Collection methods) { - this(patterns, methods, null, null, null); + RequestMappingInfo(Collection patterns, RequestMethod[] methods) { + this(patterns, RequestConditionFactory.parseMethods(methods), null, null, null); } /** * Creates a new {@code RequestMappingInfo} instance with a full set of conditions. */ public RequestMappingInfo(Collection patterns, - Collection methods, + RequestMethodsRequestCondition methodsCondition, ParamsRequestCondition paramsCondition, HeadersRequestCondition headersCondition, ConsumesRequestCondition consumesCondition) { this.patterns = asUnmodifiableSet(prependLeadingSlash(patterns)); - this.methods = asUnmodifiableSet(methods); + this.methodsCondition = methodsCondition != null ? methodsCondition : new RequestMethodsRequestCondition(); this.paramsCondition = paramsCondition != null ? paramsCondition : new ParamsRequestCondition(); this.headersCondition = headersCondition != null ? headersCondition : new HeadersRequestCondition(); this.consumesCondition = consumesCondition != null ? consumesCondition : new ConsumesRequestCondition(); @@ -111,10 +113,10 @@ public final class RequestMappingInfo { } /** - * Returns the request methods of this request key. + * Returns the request method conditions of this request key. */ - public Set getMethods() { - return methods; + public RequestMethodsRequestCondition getMethods() { + return methodsCondition; } /** @@ -158,7 +160,7 @@ public final class RequestMappingInfo { */ public RequestMappingInfo combine(RequestMappingInfo methodKey, PathMatcher pathMatcher) { Set patterns = combinePatterns(this.patterns, methodKey.patterns, pathMatcher); - Set methods = union(this.methods, methodKey.methods); + RequestMethodsRequestCondition methods = this.methodsCondition.combine(methodKey.methodsCondition); ParamsRequestCondition params = this.paramsCondition.combine(methodKey.paramsCondition); HeadersRequestCondition headers = this.headersCondition.combine(methodKey.headersCondition); ConsumesRequestCondition consumes = this.consumesCondition.combine(methodKey.consumesCondition); @@ -189,12 +191,6 @@ public final class RequestMappingInfo { return result; } - private static Set union(Collection s1, Collection s2) { - Set union = new LinkedHashSet(s1); - union.addAll(s2); - return union; - } - /** * Returns a new {@code RequestMappingInfo} that contains all conditions of this key that are relevant to the request. *