Skip to content

Commit 6c6ee7f

Browse files
committed
Make pathEquals null-safe
Signed-off-by: Sai Rohith Reddy <[email protected]>
1 parent c5a79fd commit 6c6ee7f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-core/src/main/java/org/springframework/util/StringUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,13 +818,14 @@ else if (TOP_PATH.equals(element)) {
818818
}
819819

820820
/**
821-
* Compare two paths after normalization of them.
821+
* Compare two paths after normalization of them. Results in false if any or both of
822+
* the supplied path values are {@code null}.
822823
* @param path1 first path for comparison
823824
* @param path2 second path for comparison
824825
* @return whether the two paths are equivalent after normalization
825826
*/
826827
public static boolean pathEquals(String path1, String path2) {
827-
return cleanPath(path1).equals(cleanPath(path2));
828+
return (path1 == null || path2 == null) ? false : cleanPath(path1).equals(cleanPath(path2));
828829
}
829830

830831
/**

0 commit comments

Comments
 (0)