1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Merge branch '6.5.x' into 7.0.x

This commit is contained in:
Josh Cummings
2026-03-20 21:27:04 -06:00
2 changed files with 24 additions and 0 deletions
@@ -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 + "]";
@@ -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);