Consistently skip processing of plain Java annotations
Closes gh-33580
This commit is contained in:
@@ -180,6 +180,9 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
|
||||
SimpleTypeConverter typeConverter = new SimpleTypeConverter();
|
||||
for (Annotation annotation : annotationsToSearch) {
|
||||
Class<? extends Annotation> type = annotation.annotationType();
|
||||
if (isPlainJavaAnnotation(type)) {
|
||||
continue;
|
||||
}
|
||||
boolean checkMeta = true;
|
||||
boolean fallbackToMeta = false;
|
||||
if (isQualifier(type)) {
|
||||
@@ -194,6 +197,9 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
|
||||
boolean foundMeta = false;
|
||||
for (Annotation metaAnn : type.getAnnotations()) {
|
||||
Class<? extends Annotation> metaType = metaAnn.annotationType();
|
||||
if (isPlainJavaAnnotation(metaType)) {
|
||||
continue;
|
||||
}
|
||||
if (isQualifier(metaType)) {
|
||||
foundMeta = true;
|
||||
// Only accept fallback match if @Qualifier annotation has a value...
|
||||
@@ -213,7 +219,17 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given annotation type is a recognized qualifier type.
|
||||
* Check whether the given annotation type is a plain "java." annotation,
|
||||
* typically from {@code java.lang.annotation}.
|
||||
* <p>Aligned with
|
||||
* {@code org.springframework.core.annotation.AnnotationsScanner#hasPlainJavaAnnotationsOnly}.
|
||||
*/
|
||||
private boolean isPlainJavaAnnotation(Class<? extends Annotation> annotationType) {
|
||||
return annotationType.getName().startsWith("java.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given annotation type is a recognized qualifier type.
|
||||
*/
|
||||
protected boolean isQualifier(Class<? extends Annotation> annotationType) {
|
||||
for (Class<? extends Annotation> qualifierType : this.qualifierTypes) {
|
||||
|
||||
Reference in New Issue
Block a user