Fixed inner bean name determination for multi-level nesting scenario, calculating a unique bean name as early as possible now (and for any kind of bean scope)

Our per-bean caching in AutowiredAnnotationBeanPostProcessor and co relies on unique bean names, so this change fixes potential cache mismatch problems occuring there.

Issue: SPR-11131
This commit is contained in:
Juergen Hoeller
2013-12-09 21:45:44 +01:00
parent 5dcd28761c
commit 242ecdc448
2 changed files with 9 additions and 19 deletions

View File

@@ -16,17 +16,6 @@
package org.springframework.beans.factory.xml;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -39,6 +28,8 @@ import java.util.Map;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.xml.sax.InputSource;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException;
@@ -73,7 +64,9 @@ import org.springframework.tests.sample.beans.factory.DummyFactory;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.SerializationTestUtils;
import org.springframework.util.StopWatch;
import org.xml.sax.InputSource;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
/**
* Miscellaneous tests for XML bean definitions.
@@ -256,7 +249,7 @@ public final class XmlBeanFactoryTests {
assertEquals(5, hasInnerBeans.getAge());
TestBean inner1 = (TestBean) hasInnerBeans.getSpouse();
assertNotNull(inner1);
assertEquals("innerBean", inner1.getBeanName());
assertTrue(inner1.getBeanName().startsWith("innerBean"));
assertEquals("inner1", inner1.getName());
assertEquals(6, inner1.getAge());
@@ -271,7 +264,7 @@ public final class XmlBeanFactoryTests {
TestBean innerFactory = (TestBean) friends[1];
assertEquals(DummyFactory.SINGLETON_NAME, innerFactory.getName());
TestBean inner5 = (TestBean) friends[2];
assertEquals("innerBean", inner5.getBeanName());
assertTrue(inner5.getBeanName().startsWith("innerBean"));
}
@Test