Browse Source

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.
pull/350/head
Mark Paluch 7 years ago
parent
commit
905f59bc70
  1. 4
      src/main/java/org/springframework/data/projection/SpelAwareProxyProjectionFactory.java

4
src/main/java/org/springframework/data/projection/SpelAwareProxyProjectionFactory.java

@ -17,8 +17,8 @@ package org.springframework.data.projection; @@ -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;
@ -44,7 +44,7 @@ import org.springframework.util.ReflectionUtils; @@ -44,7 +44,7 @@ import org.springframework.util.ReflectionUtils;
*/
public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory implements BeanFactoryAware {
private final Map<Class<?>, Boolean> typeCache = new HashMap<>();
private final Map<Class<?>, Boolean> typeCache = new ConcurrentHashMap<>();
private final SpelExpressionParser parser = new SpelExpressionParser();
private @Nullable BeanFactory beanFactory;

Loading…
Cancel
Save