fixed BeanPostProcessor invocation for null bean (SPR-6700)

This commit is contained in:
Juergen Hoeller
2010-01-18 18:51:28 +00:00
parent 7097a9e965
commit 95c695eb2f
4 changed files with 41 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -103,6 +103,18 @@ public class CommonAnnotationBeanPostProcessorTests {
assertTrue(bean.destroyCalled);
}
@Test
public void testPostProcessorWithNullBean() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.addBeanPostProcessor(new CommonAnnotationBeanPostProcessor());
RootBeanDefinition rbd = new RootBeanDefinition(NullFactory.class);
rbd.setFactoryMethodName("create");
bf.registerBeanDefinition("bean", rbd);
assertNull(bf.getBean("bean"));
bf.destroySingletons();
}
@Test
public void testSerialization() throws Exception {
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
@@ -578,4 +590,12 @@ public class CommonAnnotationBeanPostProcessorTests {
private INestedTestBean testBean;
}
private static class NullFactory {
public static Object create() {
return null;
}
}
}