From 113b9d131c3f2c0f4b652f30bd5930d3184ac5b5 Mon Sep 17 00:00:00 2001 From: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Date: Sat, 11 Oct 2025 11:37:00 +0800 Subject: [PATCH] Fix non-pattern package prefix check in CandidateComponentsIndex Prior to this commit, the non-pattern package prefix check used packageName.startsWith(basePackage) which incorrectly treats "com.example2.foo" as a subpackage of "com.example". Closes gh-35601 Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> --- .../springframework/context/index/CandidateComponentsIndex.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java b/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java index 45082199ab6..492fb4fb8f7 100644 --- a/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java +++ b/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java @@ -150,7 +150,7 @@ public class CandidateComponentsIndex { return pathMatcher.match(basePackage, packageName); } else { - return packageName.startsWith(basePackage); + return packageName.equals(basePackage) || packageName.startsWith(basePackage + "."); } }