Same method filtering in ConstructorResolver and getTypeForFactoryMethod
Issue: SPR-16999
(cherry picked from commit 0052c89)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -783,6 +784,15 @@ public class ConfigurationClassPostProcessorTests {
|
||||
assertSame(ctx.getBean(TestBean.class), bean.testBeans.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapInjectionFromSameConfigurationClass() {
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(MapInjectionConfiguration.class);
|
||||
MapInjectionConfiguration bean = ctx.getBean(MapInjectionConfiguration.class);
|
||||
assertNotNull(bean.testBeans);
|
||||
assertEquals(1, bean.testBeans.size());
|
||||
assertSame(ctx.getBean(Runnable.class), bean.testBeans.get("testBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanLookupFromSameConfigurationClass() {
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(BeanLookupConfiguration.class);
|
||||
@@ -1468,6 +1478,23 @@ public class ConfigurationClassPostProcessorTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class MapInjectionConfiguration {
|
||||
|
||||
@Autowired
|
||||
private Map<String, Runnable> testBeans;
|
||||
|
||||
@Bean
|
||||
Runnable testBean() {
|
||||
return () -> {};
|
||||
}
|
||||
|
||||
// Unrelated, not to be considered as a factory method
|
||||
private boolean testBean(boolean param) {
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static abstract class BeanLookupConfiguration {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user