adapted to changes in non-lenient mode
This commit is contained in:
parent
636c4901c0
commit
904c2358cd
|
|
@ -259,14 +259,12 @@ class ConstructorResolver {
|
|||
}
|
||||
|
||||
try {
|
||||
Object beanInstance = null;
|
||||
|
||||
Object beanInstance;
|
||||
|
||||
if (System.getSecurityManager() != null) {
|
||||
final Constructor ctorToUse = constructorToUse;
|
||||
final Object[] argumentsToUse = argsToUse;
|
||||
|
||||
beanInstance = AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
|
||||
public Object run() {
|
||||
return beanFactory.getInstantiationStrategy().instantiate(
|
||||
mbd, beanName, beanFactory, ctorToUse, argumentsToUse);
|
||||
|
|
@ -389,7 +387,6 @@ class ConstructorResolver {
|
|||
|
||||
final Class factoryClazz = factoryClass;
|
||||
if (System.getSecurityManager() != null) {
|
||||
|
||||
rawCandidates = AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
|
||||
public Method[] run() {
|
||||
return (mbd.isNonPublicAccessAllowed() ?
|
||||
|
|
@ -416,7 +413,7 @@ class ConstructorResolver {
|
|||
ConstructorArgumentValues resolvedValues = null;
|
||||
boolean autowiring = (mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
|
||||
int minTypeDiffWeight = Integer.MAX_VALUE;
|
||||
Set<Method> ambiguousFactoryMethods = null;
|
||||
Set<Method> ambiguousFactoryMethods = null;
|
||||
|
||||
int minNrOfArgs;
|
||||
if (explicitArgs != null) {
|
||||
|
|
@ -526,16 +523,13 @@ class ConstructorResolver {
|
|||
}
|
||||
|
||||
try {
|
||||
|
||||
Object beanInstance = null;
|
||||
|
||||
Object beanInstance;
|
||||
|
||||
if (System.getSecurityManager() != null) {
|
||||
final Object fb = factoryBean;
|
||||
final Method factoryMethod = factoryMethodToUse;
|
||||
final Object[] args = argsToUse;
|
||||
|
||||
beanInstance = AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
|
||||
public Object run() {
|
||||
return beanFactory.getInstantiationStrategy().instantiate(
|
||||
mbd, beanName, beanFactory, fb, factoryMethod, args);
|
||||
|
|
|
|||
|
|
@ -1365,36 +1365,6 @@ public final class XmlBeanFactoryTests {
|
|||
assertEquals(Boolean.TRUE, bean.boolean2);
|
||||
}
|
||||
|
||||
public @Test void testDoubleBooleanNoType() {
|
||||
XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
|
||||
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("beanWithDoubleBooleanNoType");
|
||||
bd.setLenientConstructorResolution(false);
|
||||
try {
|
||||
xbf.getBean("beanWithDoubleBooleanNoType");
|
||||
fail("Should have thrown BeanCreationException");
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
// expected
|
||||
ex.printStackTrace();
|
||||
assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous"));
|
||||
}
|
||||
}
|
||||
|
||||
public @Test void testDoubleBooleanNoTypeFactoryMethod() {
|
||||
XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
|
||||
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("beanWithDoubleBooleanNoTypeFactoryMethod");
|
||||
bd.setLenientConstructorResolution(false);
|
||||
try {
|
||||
xbf.getBean("beanWithDoubleBooleanNoTypeFactoryMethod");
|
||||
fail("Should have thrown BeanCreationException");
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
// expected
|
||||
ex.printStackTrace();
|
||||
assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous"));
|
||||
}
|
||||
}
|
||||
|
||||
public @Test void testLenientDependencyMatching() {
|
||||
XmlBeanFactory xbf = new XmlBeanFactory(CONSTRUCTOR_ARG_CONTEXT);
|
||||
LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBean");
|
||||
|
|
|
|||
Loading…
Reference in New Issue