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 89fe9fbd3b4b048bf4cd5fc789f323bf756605ce..c10d661736cd5e939a2d5fedea4980bf8e7658e2 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -419,12 +419,10 @@ public class AntPathMatcher implements PathMatcher { /** * Combine two patterns into a new pattern. - * *
This implementation simply concatenates the two patterns, unless * the first pattern contains a file extension match (e.g., {@code *.html}). * In that case, the second pattern will be merged into the first. Otherwise, * an {@code IllegalArgumentException} will be thrown. - * *
Pattern 1 | Pattern 2 | Result |
---|---|---|
/*.html | /hotels | /hotels.html |
/*.html | /*.txt | {@code IllegalArgumentException} |
The returned {@code Comparator} will {@linkplain java.util.Collections#sort(java.util.List, - * java.util.Comparator) sort} a list so that more specific patterns (without uri templates or wild cards) come before - * generic patterns. So given a list with the following patterns:
The full path given as parameter is used to test for exact matches. So when the given path is {@code /hotels/2}, - * the pattern {@code /hotels/2} will be sorted before {@code /hotels/1}. + * Given a full path, returns a {@link Comparator} suitable for sorting patterns in order of + * explicitness. + *
This{@code Comparator} will {@linkplain java.util.Collections#sort(List, Comparator) sort} + * a list so that more specific patterns (without uri templates or wild cards) come before + * generic patterns. So given a list with the following patterns: + *
The full path given as parameter is used to test for exact matches. So when the given path + * is {@code /hotels/2}, the pattern {@code /hotels/2} will be sorted before {@code /hotels/1}. * @param path the full path to use for comparison * @return a comparator capable of sorting patterns in order of explicitness */ 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 4b724929e51d93d1e599549438e48bf996be6554..2de004df88c9c97686d1390cdb6e1390094dd409 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -44,15 +44,11 @@ import static org.junit.Assert.*; */ public class AntPathMatcherTests { - private AntPathMatcher pathMatcher; + private final AntPathMatcher pathMatcher = new AntPathMatcher(); @Rule - public ExpectedException exception = ExpectedException.none(); + public final ExpectedException exception = ExpectedException.none(); - @Before - public void createMatcher() { - pathMatcher = new AntPathMatcher(); - } @Test public void match() { @@ -432,7 +428,6 @@ public class AntPathMatcherTests { assertEquals("/hotel/booking", pathMatcher.combine("/hotel/", "/booking")); // SPR-12975 } - @Ignore("Disabled until SPR-12998 is resolved") @Test public void combineWithTwoFileExtensionPatterns() { exception.expect(IllegalArgumentException.class);