diff --git a/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java b/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java index 2ba5f3ca871..0f06c419d9b 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -299,7 +299,7 @@ public class AntPathMatcher implements PathMatcher { else if (!StringUtils.hasText(pattern2)) { return pattern1; } - else if (match(pattern1, pattern2)) { + else if (!pattern1.contains("{") && match(pattern1, pattern2)) { return pattern2; } else if (pattern1.endsWith("/*")) { diff --git a/org.springframework.core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/org.springframework.core/src/test/java/org/springframework/util/AntPathMatcherTests.java index 9133c181c29..f416d17eebe 100644 --- a/org.springframework.core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/org.springframework.core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -407,7 +407,10 @@ public class AntPathMatcherTests { assertEquals("/hotel.html", pathMatcher.combine("/*.html", "/hotel.html")); assertEquals("/hotel.html", pathMatcher.combine("/*.html", "/hotel")); assertEquals("/hotel.html", pathMatcher.combine("/*.html", "/hotel.*")); + assertEquals("/*.html", pathMatcher.combine("/**", "/*.html")); + assertEquals("/*.html", pathMatcher.combine("/*", "/*.html")); assertEquals("/*.html", pathMatcher.combine("/*.*", "/*.html")); + assertEquals("/{foo}/bar", pathMatcher.combine("/{foo}", "/bar")); } @Test diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java index f6b777bd037..eeb321691f0 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationMappingUtilsTests.java @@ -148,10 +148,11 @@ public class ServletAnnotationMappingUtilsTests { @Test public void checkHeadersKeyValueNoMatchWithNegation() { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); - request.addHeader("header1", "value1"); - String[] headers = new String[]{"header1!=value1"}; - boolean result = ServletAnnotationMappingUtils.checkHeaders(headers, request); - assertFalse("Invalid request method result", result); + request.addHeader("Accept-Encoding", "gzip"); + String[] headers1 = new String[]{"Accept-Encoding!=gzip"}; + String[] headers2 = new String[]{"Accept-Encoding=gzip"}; + assertFalse(ServletAnnotationMappingUtils.checkHeaders(headers1, request)); + assertTrue(ServletAnnotationMappingUtils.checkHeaders(headers2, request)); } @Test