From 9d3779db49b291f56623b78f0f92b25838d6ca90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Wed, 21 May 2025 17:43:23 +0200 Subject: [PATCH] =?UTF-8?q?Declare=20@=E2=81=A0Contract=20for=20quote()=20?= =?UTF-8?q?&=20getFilename()=20in=20StringUtils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit declares nullability @⁠Contract annotations for quote() and getFilename() in StringUtils. Closes gh-34896 Signed-off-by: Stéphane Nicoll --- .../src/main/java/org/springframework/util/StringUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 188e1178ec..900fadf7b4 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -516,6 +516,7 @@ public abstract class StringUtils { * @return the quoted {@code String} (for example, "'myString'"), * or {@code null} if the input was {@code null} */ + @Contract("null -> null; !null -> !null") public static @Nullable String quote(@Nullable String str) { return (str != null ? "'" + str + "'" : null); } @@ -618,6 +619,7 @@ public abstract class StringUtils { * @param path the file path (may be {@code null}) * @return the extracted filename, or {@code null} if none */ + @Contract("null -> null; !null -> !null") public static @Nullable String getFilename(@Nullable String path) { if (path == null) { return null;