Workaround for generic parameter types on inner class constructors
Issue: SPR-16734
This commit is contained in:
parent
d4a55a257b
commit
a2a8d0c754
|
@ -37,6 +37,7 @@ import org.springframework.beans.factory.BeanCreationException;
|
|||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
|
||||
import org.springframework.beans.factory.annotation.Lookup;
|
||||
|
@ -351,7 +352,7 @@ public class ConfigurationClassPostProcessorTests {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // SPR-15384
|
||||
public void nestedConfigurationClassesProcessedInCorrectOrder() {
|
||||
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(ConfigWithOrderedNestedClasses.class));
|
||||
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
|
||||
|
@ -363,6 +364,19 @@ public class ConfigurationClassPostProcessorTests {
|
|||
assertSame(foo, bar.foo);
|
||||
}
|
||||
|
||||
@Test // SPR-16734
|
||||
public void innerConfigurationClassesProcessedInCorrectOrder() {
|
||||
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(ConfigWithOrderedInnerClasses.class));
|
||||
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
|
||||
pp.postProcessBeanFactory(beanFactory);
|
||||
beanFactory.addBeanPostProcessor(new AutowiredAnnotationBeanPostProcessor());
|
||||
|
||||
Foo foo = beanFactory.getBean(Foo.class);
|
||||
assertTrue(foo instanceof ExtendedFoo);
|
||||
Bar bar = beanFactory.getBean(Bar.class);
|
||||
assertSame(foo, bar.foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scopedProxyTargetMarkedAsNonAutowireCandidate() {
|
||||
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
|
||||
|
@ -890,6 +904,43 @@ public class ConfigurationClassPostProcessorTests {
|
|||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class ConfigWithOrderedInnerClasses {
|
||||
|
||||
@Configuration
|
||||
@Order(1)
|
||||
class SingletonBeanConfig {
|
||||
|
||||
public SingletonBeanConfig(ConfigWithOrderedInnerClasses other) {
|
||||
}
|
||||
|
||||
public @Bean Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public @Bean Bar bar() {
|
||||
return new Bar(foo());
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Order(2)
|
||||
class OverridingSingletonBeanConfig {
|
||||
|
||||
public OverridingSingletonBeanConfig(ObjectProvider<SingletonBeanConfig> other) {
|
||||
other.getObject();
|
||||
}
|
||||
|
||||
public @Bean ExtendedFoo foo() {
|
||||
return new ExtendedFoo();
|
||||
}
|
||||
|
||||
public @Bean Bar bar() {
|
||||
return new Bar(foo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Foo {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue