Description
Torsten Juergeleit opened SPR-259 and commented
Concurrent calls from within different threads (servlets) to AbstractApplicationContext.getBeansOfType() leads to the following exception:
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
at java.util.HashMap$KeyIterator.next(HashMap.java:818)
at org.springframework.beans.factory.support.AbstractBeanFactory.getSingletonNames(AbstractBeanFactory.java:481)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:1
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:468)
at de.deka.techarch.spring.bean.BeanUtils.getFirstInterceptedBeanOfType(BeanUtils.java:67)
at de.deka.dekanet.service.context.BusinessServiceFactory.getService(BusinessServiceFactory.java:86)
Our code which calls ListableBeanFactory.getBeansOfType() is as follows:
/**
* Returns the first bean from the {@link Map} returned by
* <code>ListableBeanFactory.getBeansOfType(type, true, true)</code>
* which is an instances of {@link java.lang.reflect.Proxy}</code>.
*/
public static final Object getFirstProxiedBeanOfType(
ListableBeanFactory factory, Class type) {
Map names = factory.getBeansOfType(type, true, true);
Iterator iter = names.keySet().iterator();
while (iter.hasNext()) {
String name = (String)iter.next();
Object bean = factory.getBean(name);
if (bean instanceof Proxy) {
return bean;
}
}
return null;
}
Affects: 1.1 RC1