From 8073efd69f481590a6d22688dc2b9a0e8f6e124e Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 14 Jul 2009 07:08:02 +0000 Subject: [PATCH] SPR-5924 - REOPENED -PathVariable mappings are greedy over hard coded mappings --- .../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 5e9b38e4698..d28f38c6a5d 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 @@ -409,7 +409,7 @@ public class AntPathMatcher implements PathMatcher { if (bracketCount1 < bracketCount2) { return -1; } - else if (bracketCount1 < bracketCount2) { + else if (bracketCount2 < bracketCount1) { return 1; } return 0; 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 10a9d313e33..e2b5c036ed0 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 @@ -388,6 +388,7 @@ public class AntPathMatcherTests { 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}/bookings/{booking}", "/hotels/{hotel}/booking")); assertEquals(-1, comparator.compare("/hotels/{hotel}", "/hotels/*")); assertEquals(1, comparator.compare("/hotels/*", "/hotels/{hotel}"));