From 304cfc0ae52f43022c9004fbba44693b4e60901f Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 13 Jul 2009 15:35:24 +0000 Subject: [PATCH] SPR-5924 - REOPENED -PathVariable mappings are greedy over hard coded mappings git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1532 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../src/main/java/org/springframework/util/AntPathMatcher.java | 2 +- .../test/java/org/springframework/util/AntPathMatcherTests.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 ec12187a41f..5e9b38e4698 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 @@ -405,7 +405,7 @@ public class AntPathMatcher implements PathMatcher { return 1; } int bracketCount1 = StringUtils.countOccurrencesOf(pattern1, "{"); - int bracketCount2 = StringUtils.countOccurrencesOf(pattern1, "{"); + int bracketCount2 = StringUtils.countOccurrencesOf(pattern2, "{"); if (bracketCount1 < bracketCount2) { return -1; } 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 5856b9970c6..10a9d313e33 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 @@ -387,6 +387,7 @@ public class AntPathMatcherTests { assertEquals(-1, comparator.compare("/hotels/new", "/hotels/{hotel}")); assertEquals(1, comparator.compare("/hotels/{hotel}", "/hotels/new")); assertEquals(0, comparator.compare("/hotels/{hotel}", "/hotels/{hotel}")); + assertEquals(-1, comparator.compare("/hotels/{hotel}/booking", "/hotels/{hotel}/bookings/{booking}")); assertEquals(-1, comparator.compare("/hotels/{hotel}", "/hotels/*")); assertEquals(1, comparator.compare("/hotels/*", "/hotels/{hotel}"));