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
This commit is contained in:
Phillip Webb
2019-05-26 14:55:54 -07:00
parent e386e53f92
commit 6f2f5bb8c1

View File

@@ -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)),