diff --git a/spring-core/src/main/java/org/springframework/core/annotation/MergedAnnotationsCollection.java b/spring-core/src/main/java/org/springframework/core/annotation/MergedAnnotationsCollection.java index 4c406494e5..9fc6cb5367 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/MergedAnnotationsCollection.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/MergedAnnotationsCollection.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -173,9 +173,8 @@ final class MergedAnnotationsCollection implements MergedAnnotations { if (!isMappingForType(mapping, requiredType)) { continue; } - MergedAnnotation candidate = (mappingIndex == 0 - ? (MergedAnnotation) root - : TypeMappedAnnotation.createIfPossible(mapping, root, IntrospectionFailureLogger.INFO)); + MergedAnnotation candidate = (mappingIndex == 0 ? (MergedAnnotation) root : + TypeMappedAnnotation.createIfPossible(mapping, root, IntrospectionFailureLogger.INFO)); if (candidate != null && (predicate == null || predicate.test(candidate))) { if (selector.isBestCandidate(candidate)) { return candidate; diff --git a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java index bc309c7254..0ff07a0992 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java @@ -596,8 +596,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn private int getAttributeIndex(String attributeName, boolean required) { Assert.hasText(attributeName, "Attribute name must not be null"); - int attributeIndex = (isFiltered(attributeName) ? -1 : - this.mapping.getAttributes().indexOf(attributeName)); + int attributeIndex = (isFiltered(attributeName) ? -1 : this.mapping.getAttributes().indexOf(attributeName)); if (attributeIndex == -1 && required) { throw new NoSuchElementException("No attribute named '" + attributeName + "' present in merged annotation " + getType().getName()); @@ -648,6 +647,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn @Nullable static TypeMappedAnnotation createIfPossible( AnnotationTypeMapping mapping, MergedAnnotation annotation, IntrospectionFailureLogger logger) { + if (annotation instanceof TypeMappedAnnotation) { TypeMappedAnnotation typeMappedAnnotation = (TypeMappedAnnotation) annotation; return createIfPossible(mapping, typeMappedAnnotation.source,