Avoid stack overflow in case of chained factory-bean references to FactoryBean class
Issue: SPR-14551
This commit is contained in:
@@ -325,8 +325,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object resolveDependency(DependencyDescriptor descriptor, String beanName) throws BeansException {
|
public Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException {
|
||||||
return resolveDependency(descriptor, beanName, null, null);
|
return resolveDependency(descriptor, requestingBeanName, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -802,10 +802,14 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
|||||||
if (objectType.value != null) {
|
if (objectType.value != null) {
|
||||||
return objectType.value;
|
return objectType.value;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// No type found for shortcut FactoryBean instance:
|
||||||
|
// fall back to full creation of the FactoryBean instance.
|
||||||
|
return super.getTypeForFactoryBean(beanName, mbd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No type found - fall back to full creation of the FactoryBean instance.
|
return null;
|
||||||
return super.getTypeForFactoryBean(beanName, mbd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -824,7 +828,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
|||||||
SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor) bp;
|
SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor) bp;
|
||||||
exposedObject = ibp.getEarlyBeanReference(exposedObject, beanName);
|
exposedObject = ibp.getEarlyBeanReference(exposedObject, beanName);
|
||||||
if (exposedObject == null) {
|
if (exposedObject == null) {
|
||||||
return exposedObject;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -122,7 +122,9 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests {
|
|||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void closeContext() {
|
public static void closeContext() {
|
||||||
applicationContext.close();
|
if (applicationContext != null) {
|
||||||
|
applicationContext.close();
|
||||||
|
}
|
||||||
applicationContext = null;
|
applicationContext = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
|
||||||
|
|
||||||
<beans>
|
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" primary="true">
|
||||||
|
|
||||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
|
||||||
<property name="persistenceXmlLocation" value="org/springframework/orm/jpa/domain/persistence-context.xml"/>
|
<property name="persistenceXmlLocation" value="org/springframework/orm/jpa/domain/persistence-context.xml"/>
|
||||||
<property name="dataSource" ref="dataSource"/>
|
<property name="dataSource" ref="dataSource"/>
|
||||||
<property name="jpaVendorAdapter">
|
<property name="jpaVendorAdapter">
|
||||||
@@ -23,4 +23,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="sessionFactory" factory-bean="entityManagerFactory" factory-method="getSessionFactory"/>
|
||||||
|
|
||||||
|
<bean id="hibernateStatistics" factory-bean="sessionFactory" factory-method="getStatistics"/>
|
||||||
|
|
||||||
|
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
Reference in New Issue
Block a user