Skip to content

Commit 6f2f5bb

Browse files
committed
Fix annotation exceptions in tight memory
Update `AnnotationTypeMapping` so that instance comparisons are no longer used when checking attribute methods. Prior to this commit, in an environment with tightly constrained memory, the method cache could be cleared and different method instances would be returned. Closes gh-23010
1 parent e386e53 commit 6f2f5bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private Method resolveAliasTarget(Method attribute, AliasFor aliasFor, boolean c
161161
StringUtils.capitalize(AttributeMethods.describe(attribute)),
162162
AttributeMethods.describe(targetAnnotation, targetAttributeName)));
163163
}
164-
if (target == attribute) {
164+
if (target.equals(attribute)) {
165165
throw new AnnotationConfigurationException(String.format(
166166
"@AliasFor declaration on %s points to itself. " +
167167
"Specify 'annotation' to point to a same-named attribute on a meta-annotation.",
@@ -182,7 +182,7 @@ private Method resolveAliasTarget(Method attribute, AliasFor aliasFor, boolean c
182182
attribute.getName()));
183183
}
184184
Method mirror = resolveAliasTarget(target, targetAliasFor, false);
185-
if (mirror != attribute) {
185+
if (!mirror.equals(attribute)) {
186186
throw new AnnotationConfigurationException(String.format(
187187
"%s must be declared as an @AliasFor '%s', not '%s'.",
188188
StringUtils.capitalize(AttributeMethods.describe(target)),

0 commit comments

Comments
 (0)