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
master
Phillip Webb 5 years ago
parent e386e53f92
commit 6f2f5bb8c1
  1. 4
      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)),

Loading…
Cancel
Save