diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index 886327e13c..580c97878f 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -696,11 +696,15 @@ public class AntPathMatcher implements PathMatcher { this.doubleWildcards++; pos += 2; } - else { + else if(!this.pattern.substring(pos - 1).equals(".*")) { this.singleWildcards++; pos++; } - } else { + else { + pos++; + } + } + else { pos++; } } diff --git a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java index 28673c2643..3ef3acd54c 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -451,6 +451,7 @@ public class AntPathMatcherTests { assertEquals(1, comparator.compare("/hotels/*/**", "/hotels/*")); assertEquals(-1, comparator.compare("/hotels/new", "/hotels/new.*")); + assertEquals(2, comparator.compare("/hotels/{hotel}", "/hotels/{hotel}.*")); //SPR-6741 assertEquals(-1, comparator.compare("/hotels/{hotel}/bookings/{booking}/cutomers/{customer}", "/hotels/**"));