From cb320468dbc88f07b72d8a949b525c5ab911bd74 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 14 Apr 2026 16:17:20 +0200 Subject: [PATCH] Further clarify semantics of HttpMethod.valueOf() See gh-36652 --- .../main/java/org/springframework/http/HttpMethod.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/HttpMethod.java b/spring-web/src/main/java/org/springframework/http/HttpMethod.java index 348692d55d0..856031d98e6 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpMethod.java +++ b/spring-web/src/main/java/org/springframework/http/HttpMethod.java @@ -112,8 +112,12 @@ public final class HttpMethod implements Comparable, Serializable { * Return an {@code HttpMethod} object for the given value. *

Note that this lookup is case-sensitive. For predefined constants, * the method value must be provided in uppercase (e.g., {@code "GET"}, - * {@code "POST"}). If no predefined constant matches, a new - * {@code HttpMethod} instance is returned for the given value as-is. + * {@code "POST"}). If no predefined constant matches, a new {@code HttpMethod} + * instance is returned for the given value as-is. For example, + * {@code HttpMethod.valueOf("GET")} resolves to {@link HttpMethod#GET}, while + * {@code HttpMethod.valueOf("get")} resolves to {@code new HttpMethod("get")}, + * and the two resulting {@code HttpMethod} instances are not + * {@linkplain #equals(Object) equal} and do not {@linkplain #matches(String) match}. * @param method the method value as a String * @return the corresponding {@code HttpMethod} */