From 6f2f5bb8c1a0926c0d2be683bb721c3966cf9c80 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sun, 26 May 2019 14:55:54 -0700 Subject: [PATCH] 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 --- .../core/annotation/AnnotationTypeMapping.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java index 501e03f280..b8dc512c99 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java @@ -161,7 +161,7 @@ final class AnnotationTypeMapping { StringUtils.capitalize(AttributeMethods.describe(attribute)), AttributeMethods.describe(targetAnnotation, targetAttributeName))); } - if (target == attribute) { + if (target.equals(attribute)) { throw new AnnotationConfigurationException(String.format( "@AliasFor declaration on %s points to itself. " + "Specify 'annotation' to point to a same-named attribute on a meta-annotation.", @@ -182,7 +182,7 @@ final class AnnotationTypeMapping { attribute.getName())); } Method mirror = resolveAliasTarget(target, targetAliasFor, false); - if (mirror != attribute) { + if (!mirror.equals(attribute)) { throw new AnnotationConfigurationException(String.format( "%s must be declared as an @AliasFor '%s', not '%s'.", StringUtils.capitalize(AttributeMethods.describe(target)),