Merge branch '6.1.x'

This commit is contained in:
Juergen Hoeller 2024-04-22 13:43:57 +02:00
commit 6a1ec0ed73
5 changed files with 15 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@ -225,7 +225,6 @@ class ConfigurationClassEnhancer {
};
return new TransformingClassGenerator(cg, transformer);
}
}

View File

@ -388,11 +388,11 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
});
// Detect any custom bean name generation strategy supplied through the enclosing application context
SingletonBeanRegistry sbr = null;
if (registry instanceof SingletonBeanRegistry _sbr) {
sbr = _sbr;
SingletonBeanRegistry singletonRegistry = null;
if (registry instanceof SingletonBeanRegistry sbr) {
singletonRegistry = sbr;
if (!this.localBeanNameGeneratorSet) {
BeanNameGenerator generator = (BeanNameGenerator) sbr.getSingleton(
BeanNameGenerator generator = (BeanNameGenerator) singletonRegistry.getSingleton(
AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
if (generator != null) {
this.componentScanBeanNameGenerator = generator;
@ -453,8 +453,8 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
while (!candidates.isEmpty());
// Register the ImportRegistry as a bean in order to support ImportAware @Configuration classes
if (sbr != null && !sbr.containsSingleton(IMPORT_REGISTRY_BEAN_NAME)) {
sbr.registerSingleton(IMPORT_REGISTRY_BEAN_NAME, parser.getImportRegistry());
if (singletonRegistry != null && !singletonRegistry.containsSingleton(IMPORT_REGISTRY_BEAN_NAME)) {
singletonRegistry.registerSingleton(IMPORT_REGISTRY_BEAN_NAME, parser.getImportRegistry());
}
// Store the PropertySourceDescriptors to contribute them Ahead-of-time if necessary

View File

@ -101,8 +101,8 @@ class ConfigurationClassPostProcessorAotContributionTests {
initializer.accept(freshBeanFactory);
freshContext.refresh();
assertThat(freshBeanFactory.getBeanPostProcessors()).filteredOn(ImportAwareAotBeanPostProcessor.class::isInstance)
.singleElement().satisfies(postProcessor -> assertPostProcessorEntry(postProcessor, ImportAwareConfiguration.class,
ImportConfiguration.class));
.singleElement().satisfies(postProcessor ->
assertPostProcessorEntry(postProcessor, ImportAwareConfiguration.class, ImportConfiguration.class));
freshContext.close();
});
}
@ -245,6 +245,7 @@ class ConfigurationClassPostProcessorAotContributionTests {
}
}
@Nested
class PropertySourceTests {
@ -410,9 +411,9 @@ class ConfigurationClassPostProcessorAotContributionTests {
@PropertySource("classpath:org/springframework/context/annotation/p?.properties")
static class PropertySourceWithWildcardLocationPatternConfiguration {
}
}
@Nested
class ConfigurationClassProxyTests {
@ -432,15 +433,14 @@ class ConfigurationClassPostProcessorAotContributionTests {
getRegisteredBean(CglibConfiguration.class))).isNotNull();
}
private RegisteredBean getRegisteredBean(Class<?> bean) {
this.beanFactory.registerBeanDefinition("test", new RootBeanDefinition(bean));
this.processor.postProcessBeanFactory(this.beanFactory);
return RegisteredBean.of(this.beanFactory, "test");
}
}
@Nullable
private BeanFactoryInitializationAotContribution getContribution(Class<?>... types) {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@ -458,8 +458,8 @@ class ConfigurationClassPostProcessorAotContributionTests {
.containsExactly(entry(key.getName(), value.getName()));
}
static class CustomPropertySourcesFactory extends DefaultPropertySourceFactory {
static class CustomPropertySourcesFactory extends DefaultPropertySourceFactory {
}
}

View File

@ -75,7 +75,7 @@ public class ReflectUtils {
Throwable throwable = null;
try {
classLoaderDefineClass = ClassLoader.class.getDeclaredMethod("defineClass",
String.class, byte[].class, Integer.TYPE, Integer.TYPE, ProtectionDomain.class);
String.class, byte[].class, Integer.TYPE, Integer.TYPE, ProtectionDomain.class);
}
catch (Throwable t) {
classLoaderDefineClass = null;

View File

@ -57,7 +57,7 @@ public class MethodProxy {
proxy.createInfo = new CreateInfo(c1, c2);
// SPRING PATCH BEGIN
if (!c1.isInterface() && c1 != Object.class && !Factory.class.isAssignableFrom(c2)) {
if (c1 != Object.class && c1.isAssignableFrom(c2.getSuperclass()) && !Factory.class.isAssignableFrom(c2)) {
// Try early initialization for overridden methods on specifically purposed subclasses
try {
proxy.init();