DATACMNS-1415 - Use thread-safe caching in SpelAwareProxyProjectionFactory.

We now use ConcurrentHashMap as type instead of HashMap to properly synchronize concurrent updates to missing cache elements.

The previously used HashMap was not thread-safe so concurrent modifications resulted in ConcurrentModificationException.
This commit is contained in:
Mark Paluch
2018-11-12 16:01:21 +01:00
parent 25f93eb2fc
commit f0c73b6346

View File

@@ -17,8 +17,8 @@ package org.springframework.data.projection;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.beans.BeansException;
@@ -41,7 +41,7 @@ import org.springframework.util.ReflectionUtils;
*/
public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory implements BeanFactoryAware {
private final Map<Class<?>, Boolean> typeCache = new HashMap<Class<?>, Boolean>();
private final Map<Class<?>, Boolean> typeCache = new ConcurrentHashMap<Class<?>, Boolean>();
private final SpelExpressionParser parser = new SpelExpressionParser();
private BeanFactory beanFactory;