Merge branch '6.5.x' into 7.0.x
This commit is contained in:
+13
@@ -339,6 +339,19 @@ public final class PathPatternRequestMatcher implements RequestMatcher {
|
||||
return this.method.name().equals(request.getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof HttpMethodRequestMatcher that)) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.method, that.method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HttpMethod [" + this.method + "]";
|
||||
|
||||
+11
@@ -154,6 +154,17 @@ public class PathPatternRequestMatcherTests {
|
||||
assertThat(matcher.matches(mock)).isFalse();
|
||||
}
|
||||
|
||||
// gh-18911
|
||||
@Test
|
||||
void testEqualsWithSameAndDifferentHttpMethod() {
|
||||
PathPatternRequestMatcher.Builder builder = PathPatternRequestMatcher.withDefaults();
|
||||
PathPatternRequestMatcher matcher1 = builder.matcher(HttpMethod.GET, "/foo");
|
||||
PathPatternRequestMatcher matcher2 = builder.matcher(HttpMethod.GET, "/foo");
|
||||
PathPatternRequestMatcher matcher3 = builder.matcher(HttpMethod.POST, "/foo");
|
||||
assertThat(matcher1).isEqualTo(matcher2);
|
||||
assertThat(matcher1).isNotEqualTo(matcher3);
|
||||
}
|
||||
|
||||
MockHttpServletRequest request(String uri) {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", uri);
|
||||
ServletRequestPathUtils.parseAndCache(request);
|
||||
|
||||
Reference in New Issue
Block a user