Buggy code:
public class SpringBeanLocator implements IProxyTargetLocator { private static final long serialVersionUID = 1L ; private transient WeakReference < Class < ? > > beanTypeCache ; private final String beanTypeName ; private String beanName ; private ISpringContextLocator springContextLocator ; private Boolean singletonCache = null ; public SpringBeanLocator ( final Class < ? > beanType , final ISpringContextLocator locator ) { } public SpringBeanLocator ( final String beanName , final Class < ? > beanType , final ISpringContextLocator locator ) { } private final String getBeanNameOfClass ( final ApplicationContext ctx , final Class < ? > clazz ) { List < String > names = new ArrayList < String > ( Arrays . asList ( BeanFactoryUtils . beanNamesForTypeIncludingAncestors ( ctx , clazz ) ) ) ; if ( ctx instanceof AbstractApplicationContext ) { Iterator < String > it = names . iterator ( ) ; while ( it . hasNext ( ) ) { String possibility = it . next ( ) ; BeanDefinition beanDef = getBeanDefinition ( ( ( AbstractApplicationContext ) ( ctx ) ) . getBeanFactory ( ) , possibility ) ; if ( ( ( BeanFactoryUtils . isFactoryDereference ( possibility ) ) || ( possibility . startsWith ( "scopedTarget." ) ) ) || ( ! ( beanDef . isAutowireCandidate ( ) ) ) ) { it . remove ( ) ; } } } if ( names . isEmpty ( ) ) { throw new IllegalStateException ( ( ( "bean<seq2seq4repair_space>of<seq2seq4repair_space>type<seq2seq4repair_space>[" + ( clazz . getName ( ) ) ) + "]<seq2seq4repair_space>not<seq2seq4repair_space>found" ) ) ; } else if ( ( names . size ( ) ) > 1 ) { if ( ctx instanceof AbstractApplicationContext ) { List < String > primaries = new ArrayList < String > ( ) ; for ( String name : names ) { BeanDefinition beanDef = getBeanDefinition ( ( ( AbstractApplicationContext ) ( ctx ) ) . getBeanFactory ( ) , name ) ; if ( beanDef instanceof AbstractBeanDefinition ) { <START_BUG> if ( ( ( AbstractBeanDefinition ) ( beanDef ) ) . isPrimary ( ) ) { <END_BUG> primaries . add ( name ) ; } } } if ( ( primaries . size ( ) ) == 1 ) { return primaries . get ( 0 ) ; } } StringBuilder msg = new StringBuilder ( ) ; msg . append ( "More<seq2seq4repair_space>than<seq2seq4repair_space>one<seq2seq4repair_space>bean<seq2seq4repair_space>of<seq2seq4repair_space>type<seq2seq4repair_space>[" ) ; msg . append ( clazz . getName ( ) ) ; msg . append ( "]<seq2seq4repair_space>found,<seq2seq4repair_space>you<seq2seq4repair_space>have<seq2seq4repair_space>to<seq2seq4repair_space>specify<seq2seq4repair_space>the<seq2seq4repair_space>name<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>bean<seq2seq4repair_space>" ) ; msg . append ( "(@SpringBean(name=\"foo\"))<seq2seq4repair_space>in<seq2seq4repair_space>order<seq2seq4repair_space>to<seq2seq4repair_space>resolve<seq2seq4repair_space>this<seq2seq4repair_space>conflict.<seq2seq4repair_space>" ) ; msg . append ( "Matched<seq2seq4repair_space>beans:<seq2seq4repair_space>" ) ; msg . append ( Strings . join ( "," , names . toArray ( new String [ names . size ( ) ] ) ) ) ; throw new IllegalStateException ( msg . toString ( ) ) ; } else { return names . get ( 0 ) ; } } private BeanDefinition getBeanDefinition ( final ConfigurableListableBeanFactory beanFactory , final String name ) { } public boolean isSingletonBean ( ) { } public Class < ? > getBeanType ( ) { } public Object locateProxyTarget ( ) { } private ApplicationContext getSpringContext ( ) { } public final String getBeanName ( ) { } public final ISpringContextLocator getSpringContextLocator ( ) { } private final Object lookupSpringBean ( final ApplicationContext ctx , final Class < ? > clazz ) { } private static Object lookupSpringBean ( final ApplicationContext ctx , final String name , final Class < ? > clazz ) { } @ Override public boolean equals ( final Object obj ) { } @ Override public int hashCode ( ) { } }

Fix:
if ( beanDef . isPrimary ( ) ) {