Buggy code:
public class CommonAnnotationBeanPostProcessorTests { @ Test public void testPostConstructAndPreDestroy ( ) { } @ Test public void testPostConstructAndPreDestroyWithPostProcessor ( ) { } @ Test public void testPostConstructAndPreDestroyWithApplicationContextAndPostProcessor ( ) { } @ Test public void testPostConstructAndPreDestroyWithManualConfiguration ( ) { } @ Test public void testSerialization ( ) throws Exception { } @ Test public void testSerializationWithManualConfiguration ( ) throws Exception { } @ Test public void testResourceInjection ( ) { } @ Test public void testResourceInjectionWithTwoProcessors ( ) { } @ Test public void testResourceInjectionFromJndi ( ) { } @ Test public void testExtendedResourceInjection ( ) { } @ Test public void testExtendedResourceInjectionWithOverriding ( ) { DefaultListableBeanFactory bf = new DefaultListableBeanFactory ( ) ; CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor ( ) ; bpp . setBeanFactory ( bf ) ; bf . addBeanPostProcessor ( bpp ) ; bf . registerResolvableDependency ( BeanFactory . class , bf ) ; PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer ( ) ; Properties props = new Properties ( ) ; props . setProperty ( "tb" , "testBean3" ) ; ppc . setProperties ( props ) ; ppc . postProcessBeanFactory ( bf ) ; RootBeanDefinition annotatedBd = new RootBeanDefinition ( CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean . class ) ; TestBean tb5 = new TestBean ( ) ; <START_BUG> annotatedBd . getPropertyValues ( ) . addPropertyValue ( "testBean2" , tb5 ) ; <END_BUG> bf . registerBeanDefinition ( "annotatedBean" , annotatedBd ) ; bf . registerBeanDefinition ( "annotatedBean2" , new RootBeanDefinition ( CommonAnnotationBeanPostProcessorTests . NamedResourceInjectionBean . class ) ) ; TestBean tb = new TestBean ( ) ; bf . registerSingleton ( "testBean" , tb ) ; TestBean tb2 = new TestBean ( ) ; bf . registerSingleton ( "testBean2" , tb2 ) ; TestBean tb3 = new TestBean ( ) ; bf . registerSingleton ( "testBean3" , tb3 ) ; TestBean tb4 = new TestBean ( ) ; bf . registerSingleton ( "testBean4" , tb4 ) ; NestedTestBean tb6 = new NestedTestBean ( ) ; bf . registerSingleton ( "xy" , tb6 ) ; CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean bean = ( ( CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean ) ( bf . getBean ( "annotatedBean" ) ) ) ; assertTrue ( bean . initCalled ) ; assertTrue ( bean . init2Called ) ; assertSame ( tb , bean . getTestBean ( ) ) ; assertSame ( tb5 , bean . getTestBean2 ( ) ) ; assertSame ( tb4 , bean . getTestBean3 ( ) ) ; assertSame ( tb3 , bean . getTestBean4 ( ) ) ; assertSame ( tb6 , bean . testBean5 ) ; assertSame ( tb6 , bean . testBean6 ) ; assertSame ( bf , bean . beanFactory ) ; try { bf . getBean ( "annotatedBean2" ) ; } catch ( BeanCreationException ex ) { assertTrue ( ( ( ex . getRootCause ( ) ) instanceof NoSuchBeanDefinitionException ) ) ; NoSuchBeanDefinitionException innerEx = ( ( NoSuchBeanDefinitionException ) ( ex . getRootCause ( ) ) ) ; assertEquals ( "testBean9" , innerEx . getBeanName ( ) ) ; } bf . destroySingletons ( ) ; assertTrue ( bean . destroyCalled ) ; assertTrue ( bean . destroy2Called ) ; } @ Test public void testExtendedEjbInjection ( ) { } public static class AnnotatedInitDestroyBean { public boolean initCalled = false ; public boolean destroyCalled = false ; @ PostConstruct private void init ( ) { } @ PreDestroy private void destroy ( ) { } } public static class InitDestroyBeanPostProcessor implements DestructionAwareBeanPostProcessor { public Object postProcessBeforeInitialization ( Object bean , String beanName ) throws BeansException { } public Object postProcessAfterInitialization ( Object bean , String beanName ) throws BeansException { } public void postProcessBeforeDestruction ( Object bean , String beanName ) throws BeansException { } } public static class ResourceInjectionBean extends CommonAnnotationBeanPostProcessorTests . AnnotatedInitDestroyBean { public boolean init2Called = false ; public boolean init3Called = false ; public boolean destroy2Called = false ; public boolean destroy3Called = false ; @ Resource private TestBean testBean ; private TestBean testBean2 ; @ PostConstruct protected void init2 ( ) { } @ PostConstruct private void init ( ) { } @ PreDestroy protected void destroy2 ( ) { } @ PreDestroy private void destroy ( ) { } @ Resource public void setTestBean2 ( TestBean testBean2 ) { } public TestBean getTestBean ( ) { } public TestBean getTestBean2 ( ) { } } public static class ExtendedResourceInjectionBean extends CommonAnnotationBeanPostProcessorTests . ResourceInjectionBean { @ Resource ( name = "testBean4" , type = TestBean . class ) protected ITestBean testBean3 ; private ITestBean testBean4 ; @ Resource private INestedTestBean testBean5 ; private INestedTestBean testBean6 ; @ Resource private BeanFactory beanFactory ; @ Resource public void setTestBean2 ( TestBean testBean2 ) { } @ Resource ( name = "${tb}" , type = ITestBean . class ) private void setTestBean4 ( ITestBean testBean4 ) { } @ Resource public void setTestBean6 ( INestedTestBean testBean6 ) { } public ITestBean getTestBean3 ( ) { } public ITestBean getTestBean4 ( ) { } @ PostConstruct protected void init2 ( ) { } @ PreDestroy protected void destroy2 ( ) { } } public static class ExtendedEjbInjectionBean extends CommonAnnotationBeanPostProcessorTests . ResourceInjectionBean { @ EJB ( name = "testBean4" , beanInterface = TestBean . class ) protected ITestBean testBean3 ; private ITestBean testBean4 ; @ EJB private INestedTestBean testBean5 ; private INestedTestBean testBean6 ; @ Resource private BeanFactory beanFactory ; @ EJB public void setTestBean2 ( TestBean testBean2 ) { } @ EJB ( beanName = "testBean3" , beanInterface = ITestBean . class ) private void setTestBean4 ( ITestBean testBean4 ) { } @ EJB public void setTestBean6 ( INestedTestBean testBean6 ) { } public ITestBean getTestBean3 ( ) { } public ITestBean getTestBean4 ( ) { } @ PostConstruct protected void init2 ( ) { } @ PreDestroy protected void destroy2 ( ) { } } private static class NamedResourceInjectionBean { @ Resource ( name = "testBean9" ) private INestedTestBean testBean ; } }

Fix:
annotatedBd . getPropertyValues ( ) . add ( "testBean2" , tb5 ) ;