Polishing

This commit is contained in:
Juergen Hoeller 2024-02-20 15:42:15 +01:00
parent 85c9279431
commit 93f0ec2fa1
3 changed files with 13 additions and 12 deletions

View File

@ -282,7 +282,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
}
if (actualValue == null && attributeName.equals(AutowireCandidateQualifier.VALUE_KEY) &&
expectedValue instanceof String name && bdHolder.matchesName(name)) {
// Fall back on bean name (or alias) match
// Finally, check bean name (or alias) match
continue;
}
if (actualValue == null && qualifier != null) {
@ -333,8 +333,8 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
*/
@Override
public boolean hasQualifier(DependencyDescriptor descriptor) {
for (Annotation ann : descriptor.getAnnotations()) {
if (isQualifier(ann.annotationType())) {
for (Annotation annotation : descriptor.getAnnotations()) {
if (isQualifier(annotation.annotationType())) {
return true;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2024 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.
@ -81,6 +81,7 @@ import java.lang.annotation.Target;
* @see Bean
* @see ComponentScan
* @see org.springframework.stereotype.Component
* @see org.springframework.beans.factory.config.BeanDefinition#setPrimary
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -59,8 +59,8 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
void generateApplicationContextWithAutowiring() {
GenericApplicationContext context = new AnnotationConfigApplicationContext();
context.registerBeanDefinition("autowiredComponent", new RootBeanDefinition(AutowiredComponent.class));
context.registerBeanDefinition("number", BeanDefinitionBuilder.rootBeanDefinition(Integer.class, "valueOf")
.addConstructorArgValue("42").getBeanDefinition());
context.registerBeanDefinition("number", BeanDefinitionBuilder.rootBeanDefinition(
Integer.class, "valueOf").addConstructorArgValue("42").getBeanDefinition());
compile(context, (hints, invocations) -> assertThat(invocations).match(hints));
}
@ -89,8 +89,10 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
compile(context, (hints, invocations) -> assertThat(invocations).match(hints));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private void compile(GenericApplicationContext applicationContext, BiConsumer<RuntimeHints, RuntimeHintsInvocations> initializationResult) {
@SuppressWarnings({"rawtypes", "unchecked"})
private void compile(GenericApplicationContext applicationContext,
BiConsumer<RuntimeHints, RuntimeHintsInvocations> initializationResult) {
ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator();
TestGenerationContext generationContext = new TestGenerationContext();
generator.processAheadOfTime(applicationContext, generationContext);
@ -107,17 +109,15 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
});
}
public interface Destroyable {
@PreDestroy
default void destroy() {
}
}
public static class InheritedDestroy implements Destroyable {
}
}