Align internal caches with core framework patterns.
Initialize maps and sets with size where possible. Closes #3067 Original pull request: #3073
This commit is contained in:
committed by
Mark Paluch
parent
d4301eea78
commit
b21b2e8934
@@ -19,6 +19,7 @@ import java.lang.annotation.Annotation;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -40,7 +41,6 @@ import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
import org.springframework.data.util.Lazy;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
/**
|
||||
* {@link AuditableBeanWrapperFactory} that will create am {@link AuditableBeanWrapper} using mapping information
|
||||
@@ -67,7 +67,7 @@ public class MappingAuditableBeanWrapperFactory extends DefaultAuditableBeanWrap
|
||||
Assert.notNull(entities, "PersistentEntities must not be null");
|
||||
|
||||
this.entities = entities;
|
||||
this.metadataCache = new ConcurrentReferenceHashMap<>();
|
||||
this.metadataCache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,12 +32,14 @@ import org.springframework.util.ObjectUtils;
|
||||
public class SimplePropertyValueConverterRegistry<P extends PersistentProperty<P>>
|
||||
implements ValueConverterRegistry<P> {
|
||||
|
||||
private final Map<Key, PropertyValueConverter<?, ?, ? extends ValueConversionContext<P>>> converterRegistrationMap = new LinkedHashMap<>();
|
||||
private final Map<Key, PropertyValueConverter<?, ?, ? extends ValueConversionContext<P>>> converterRegistrationMap;
|
||||
|
||||
public SimplePropertyValueConverterRegistry() {}
|
||||
public SimplePropertyValueConverterRegistry() {
|
||||
this.converterRegistrationMap = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
SimplePropertyValueConverterRegistry(SimplePropertyValueConverterRegistry<P> source) {
|
||||
this.converterRegistrationMap.putAll(source.converterRegistrationMap);
|
||||
this.converterRegistrationMap = new LinkedHashMap<>(source.converterRegistrationMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -775,12 +775,14 @@ public interface ExampleMatcher {
|
||||
*/
|
||||
class PropertySpecifiers {
|
||||
|
||||
private final Map<String, PropertySpecifier> propertySpecifiers = new LinkedHashMap<>();
|
||||
private final Map<String, PropertySpecifier> propertySpecifiers;
|
||||
|
||||
PropertySpecifiers() {}
|
||||
PropertySpecifiers() {
|
||||
this. propertySpecifiers = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
PropertySpecifiers(PropertySpecifiers propertySpecifiers) {
|
||||
this.propertySpecifiers.putAll(propertySpecifiers.propertySpecifiers);
|
||||
this.propertySpecifiers = new LinkedHashMap<>(propertySpecifiers.propertySpecifiers);
|
||||
}
|
||||
|
||||
public void add(PropertySpecifier specifier) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public enum DistanceFormatter implements Converter<String, Distance>, Formatter<
|
||||
|
||||
static {
|
||||
|
||||
Map<String, Metric> metrics = new LinkedHashMap<>();
|
||||
Map<String, Metric> metrics = new LinkedHashMap<>(Metrics.values().length);
|
||||
|
||||
for (Metric metric : Metrics.values()) {
|
||||
metrics.put(metric.getAbbreviation(), metric);
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.mapping.callback;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -26,7 +27,6 @@ import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
class DefaultEntityCallbacks implements EntityCallbacks {
|
||||
|
||||
private final Map<Class<?>, Method> callbackMethodCache = new ConcurrentReferenceHashMap<>(64);
|
||||
private final Map<Class<?>, Method> callbackMethodCache = new ConcurrentHashMap<>(64);
|
||||
private final SimpleEntityCallbackInvoker callbackInvoker = new SimpleEntityCallbackInvoker();
|
||||
private final EntityCallbackDiscoverer callbackDiscoverer;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -28,7 +29,6 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
class DefaultReactiveEntityCallbacks implements ReactiveEntityCallbacks {
|
||||
|
||||
private final Map<Class<?>, Method> callbackMethodCache = new ConcurrentReferenceHashMap<>(64);
|
||||
private final Map<Class<?>, Method> callbackMethodCache = new ConcurrentHashMap<>(64);
|
||||
private final ReactiveEntityCallbackInvoker callbackInvoker = new DefaultReactiveEntityCallbackInvoker();
|
||||
private final EntityCallbackDiscoverer callbackDiscoverer;
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.comparator.Comparators;
|
||||
|
||||
@@ -54,7 +53,7 @@ class EntityCallbackDiscoverer {
|
||||
|
||||
private final CallbackRetriever defaultRetriever = new CallbackRetriever();
|
||||
private final Map<CallbackCacheKey, CallbackRetriever> retrieverCache = new ConcurrentHashMap<>(64);
|
||||
private final Map<Class<?>, ResolvableType> entityTypeCache = new ConcurrentReferenceHashMap<>(64);
|
||||
private final Map<Class<?>, ResolvableType> entityTypeCache = new ConcurrentHashMap<>(64);
|
||||
|
||||
@Nullable private ClassLoader beanClassLoader;
|
||||
|
||||
|
||||
@@ -461,7 +461,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
|
||||
|
||||
if (shouldCreateProperties(userTypeInformation)) {
|
||||
PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(type);
|
||||
Map<String, PropertyDescriptor> descriptors = new HashMap<>();
|
||||
Map<String, PropertyDescriptor> descriptors = new HashMap<>(pds.length);
|
||||
|
||||
for (PropertyDescriptor descriptor : pds) {
|
||||
descriptors.put(descriptor.getName(), descriptor);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.mapping.context;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -33,7 +34,6 @@ import org.springframework.data.util.StreamUtils;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
|
||||
|
||||
private static final Predicate<PersistentProperty<? extends PersistentProperty<?>>> IS_ENTITY = PersistentProperty::isEntity;
|
||||
|
||||
private final Map<TypeAndPath, PathResolution> propertyPaths = new ConcurrentReferenceHashMap<>();
|
||||
private final Map<TypeAndPath, PathResolution> propertyPaths = new ConcurrentHashMap<>();
|
||||
private final MappingContext<E, P> context;
|
||||
|
||||
public PersistentPropertyPathFactory(MappingContext<E, P> context) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
@@ -46,8 +47,6 @@ import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -117,9 +116,9 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
this.associations = comparator == null ? new HashSet<>() : new TreeSet<>(new AssociationComparator<>(comparator));
|
||||
|
||||
this.propertyCache = new HashMap<>(16, 1f);
|
||||
this.annotationCache = new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK);
|
||||
this.annotationCache = new ConcurrentHashMap<>(16);
|
||||
this.propertyAnnotationCache = CollectionUtils
|
||||
.toMultiValueMap(new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK));
|
||||
.toMultiValueMap(new ConcurrentHashMap<>(16));
|
||||
this.propertyAccessorFactory = BeanWrapperPropertyAccessorFactory.INSTANCE;
|
||||
this.typeAlias = Lazy.of(() -> getAliasFromAnnotation(getType()));
|
||||
this.isNewStrategy = Lazy.of(() -> Persistable.class.isAssignableFrom(information.getType()) //
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.util.KotlinReflectionUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1395,7 +1395,7 @@ public class ClassGeneratingPropertyAccessorFactory implements PersistentPropert
|
||||
private static Map<String, PropertyStackAddress> createPropertyStackMap(
|
||||
List<PersistentProperty<?>> persistentProperties) {
|
||||
|
||||
Map<String, PropertyStackAddress> stackmap = new HashMap<>();
|
||||
Map<String, PropertyStackAddress> stackmap = new HashMap<>(persistentProperties.size());
|
||||
|
||||
for (PersistentProperty<?> property : persistentProperties) {
|
||||
stackmap.put(property.getName(), new PropertyStackAddress(new Label(), property.getName().hashCode()));
|
||||
|
||||
@@ -22,14 +22,13 @@ import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.aop.ProxyMethodInvocation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -43,7 +42,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
public class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor {
|
||||
|
||||
private static final Lookup LOOKUP = MethodHandles.lookup();
|
||||
private final Map<Method, MethodHandle> methodHandleCache = new ConcurrentReferenceHashMap<>(10, ReferenceType.WEAK);
|
||||
private final Map<Method, MethodHandle> methodHandleCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Returns whether the {@code interfaceClass} declares {@link Method#isDefault() default methods}.
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
@@ -34,7 +35,6 @@ import org.springframework.data.util.NullableWrapperConverters;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
/**
|
||||
* A {@link ProjectionFactory} to create JDK proxies to back interfaces and handle method invocations on them. By
|
||||
@@ -60,7 +60,7 @@ class ProxyProjectionFactory implements ProjectionFactory, BeanClassLoaderAware
|
||||
}
|
||||
|
||||
private final List<MethodInterceptorFactory> factories;
|
||||
private final Map<Class<?>, ProjectionMetadata> projectionInformationCache = new ConcurrentReferenceHashMap<>();
|
||||
private final Map<Class<?>, ProjectionMetadata> projectionInformationCache = new ConcurrentHashMap<>();
|
||||
private @Nullable ClassLoader classLoader;
|
||||
|
||||
private final Lazy<DefaultMethodInvokingMethodInterceptor> defaultMethodInvokingMethodInterceptor = Lazy
|
||||
|
||||
@@ -107,9 +107,10 @@ class SpelEvaluatingMethodInterceptor implements MethodInterceptor {
|
||||
private static Map<Integer, Expression> potentiallyCreateExpressionsForMethodsOnTargetInterface(
|
||||
ExpressionParser parser, Class<?> targetInterface) {
|
||||
|
||||
Map<Integer, Expression> expressions = new HashMap<>();
|
||||
Method[] methods = targetInterface.getMethods();
|
||||
Map<Integer, Expression> expressions = new HashMap<>(methods.length);
|
||||
|
||||
for (Method method : targetInterface.getMethods()) {
|
||||
for (Method method : methods) {
|
||||
|
||||
Value value = AnnotationUtils.findAnnotation(method, Value.class);
|
||||
if (value == null) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.querydsl.binding;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -30,7 +31,6 @@ import org.springframework.data.querydsl.EntityPathResolver;
|
||||
import org.springframework.data.repository.support.Repositories;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
import com.querydsl.core.types.EntityPath;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class QuerydslBindingsFactory implements ApplicationContextAware {
|
||||
Assert.notNull(entityPathResolver, "EntityPathResolver must not be null");
|
||||
|
||||
this.entityPathResolver = entityPathResolver;
|
||||
this.entityPaths = new ConcurrentReferenceHashMap<>();
|
||||
this.entityPaths = new ConcurrentHashMap<>();
|
||||
this.beanFactory = Optional.empty();
|
||||
this.repositories = Optional.empty();
|
||||
this.defaultCustomizer = NoOpCustomizer.INSTANCE;
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.repository.core.support;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
@@ -49,7 +50,7 @@ import org.springframework.util.ObjectUtils;
|
||||
public class MethodInvocationValidator implements MethodInterceptor {
|
||||
|
||||
private final ParameterNameDiscoverer discoverer = new DefaultParameterNameDiscoverer();
|
||||
private final Map<Method, Nullability> nullabilityCache = new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK);
|
||||
private final Map<Method, Nullability> nullabilityCache = new ConcurrentHashMap<>(16);
|
||||
|
||||
/**
|
||||
* Returns {@literal true} if the {@code repositoryInterface} is supported by this interceptor.
|
||||
|
||||
@@ -92,9 +92,10 @@ class QueryExecutorMethodInterceptor implements MethodInterceptor {
|
||||
private Map<Method, RepositoryQuery> mapMethodsToQuery(RepositoryInformation repositoryInformation,
|
||||
QueryLookupStrategy lookupStrategy, ProjectionFactory projectionFactory) {
|
||||
|
||||
Map<Method, RepositoryQuery> result = new HashMap<>();
|
||||
List<Method> queryMethods = repositoryInformation.getQueryMethods().toList();
|
||||
Map<Method, RepositoryQuery> result = new HashMap<>(queryMethods.size());
|
||||
|
||||
for (Method method : repositoryInformation.getQueryMethods()) {
|
||||
for (Method method : queryMethods) {
|
||||
|
||||
Pair<Method, RepositoryQuery> pair = lookupQuery(method, repositoryInformation, lookupStrategy,
|
||||
projectionFactory);
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.springframework.data.util.Streamable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -101,7 +100,7 @@ public class RepositoryComposition {
|
||||
private static final RepositoryComposition EMPTY = new RepositoryComposition(null, RepositoryFragments.empty(),
|
||||
MethodLookups.direct(), PASSTHRU_ARG_CONVERTER);
|
||||
|
||||
private final Map<Method, Method> methodCache = new ConcurrentReferenceHashMap<>();
|
||||
private final Map<Method, Method> methodCache = new ConcurrentHashMap<>();
|
||||
private final RepositoryFragments fragments;
|
||||
private final MethodLookup methodLookup;
|
||||
private final BiFunction<Method, Object[], Object[]> argumentConverter;
|
||||
@@ -365,7 +364,7 @@ public class RepositoryComposition {
|
||||
|
||||
static final RepositoryFragments EMPTY = new RepositoryFragments(Collections.emptyList());
|
||||
|
||||
private final Map<Method, RepositoryFragment<?>> fragmentCache = new ConcurrentReferenceHashMap<>();
|
||||
private final Map<Method, RepositoryFragment<?>> fragmentCache = new ConcurrentHashMap<>();
|
||||
private final Map<Method, RepositoryMethodInvoker> invocationMetadataCache = new ConcurrentHashMap<>();
|
||||
private final List<RepositoryFragment<?>> fragments;
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -66,8 +66,6 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.interceptor.TransactionalProxy;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -110,7 +108,7 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware,
|
||||
@SuppressWarnings("null")
|
||||
public RepositoryFactorySupport() {
|
||||
|
||||
this.repositoryInformationCache = new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK);
|
||||
this.repositoryInformationCache = new ConcurrentHashMap<>(16);
|
||||
this.postProcessors = new ArrayList<>();
|
||||
|
||||
this.repositoryBaseClass = Optional.empty();
|
||||
@@ -727,7 +725,7 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware,
|
||||
*/
|
||||
static class RepositoryValidator {
|
||||
|
||||
static Map<Class<?>, String> WELL_KNOWN_EXECUTORS = new HashMap<>();
|
||||
static Map<Class<?>, String> WELL_KNOWN_EXECUTORS = new HashMap<>(4, 1f);
|
||||
|
||||
static {
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ExtensionAwareQueryMethodEvaluationContextProvider implements Query
|
||||
*/
|
||||
static Map<String, Object> collectVariables(Parameters<?, ?> parameters, Object[] arguments) {
|
||||
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
Map<String, Object> variables = new HashMap<>(parameters.getNumberOfParameters());
|
||||
|
||||
parameters.stream()//
|
||||
.filter(Parameter::isSpecialParameter)//
|
||||
|
||||
@@ -79,11 +79,11 @@ public abstract class QueryExecutionConverters {
|
||||
private static final boolean VAVR_PRESENT = ClassUtils.isPresent("io.vavr.control.Try",
|
||||
QueryExecutionConverters.class.getClassLoader());
|
||||
|
||||
private static final Set<WrapperType> WRAPPER_TYPES = new HashSet<>();
|
||||
private static final Set<WrapperType> UNWRAPPER_TYPES = new HashSet<WrapperType>();
|
||||
private static final Set<WrapperType> WRAPPER_TYPES = new HashSet<>(10, 1f);
|
||||
private static final Set<WrapperType> UNWRAPPER_TYPES = new HashSet<WrapperType>(10, 1f);
|
||||
private static final Set<Function<Object, Object>> UNWRAPPERS = new HashSet<>();
|
||||
private static final Set<Class<?>> ALLOWED_PAGEABLE_TYPES = new HashSet<>();
|
||||
private static final Map<Class<?>, ExecutionAdapter> EXECUTION_ADAPTER = new HashMap<>();
|
||||
private static final Map<Class<?>, ExecutionAdapter> EXECUTION_ADAPTER = new HashMap<>(3, 1f);
|
||||
private static final Map<Class<?>, Boolean> supportsCache = new ConcurrentReferenceHashMap<>();
|
||||
private static final TypeInformation<Void> VOID_INFORMATION = TypeInformation.of(Void.class);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.beans.PropertyDescriptor;
|
||||
import java.beans.SimpleBeanInfo;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -59,9 +60,10 @@ public class KotlinBeanInfoFactory implements BeanInfoFactory, Ordered {
|
||||
}
|
||||
|
||||
KClass<?> kotlinClass = JvmClassMappingKt.getKotlinClass(beanClass);
|
||||
Set<PropertyDescriptor> pds = new LinkedHashSet<>();
|
||||
Collection<KCallable<?>> members = kotlinClass.getMembers();
|
||||
Set<PropertyDescriptor> pds = new LinkedHashSet<>(members.size());
|
||||
|
||||
for (KCallable<?> member : kotlinClass.getMembers()) {
|
||||
for (KCallable<?> member : members) {
|
||||
|
||||
if (member instanceof KProperty<?> property) {
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
@@ -32,7 +33,6 @@ import org.springframework.core.convert.converter.GenericConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
@@ -67,7 +67,7 @@ public abstract class NullableWrapperConverters {
|
||||
private static final Set<WrapperType> WRAPPER_TYPES = new HashSet<WrapperType>();
|
||||
private static final Set<WrapperType> UNWRAPPER_TYPES = new HashSet<WrapperType>();
|
||||
private static final Set<Converter<Object, Object>> UNWRAPPERS = new HashSet<Converter<Object, Object>>();
|
||||
private static final Map<Class<?>, Boolean> supportsCache = new ConcurrentReferenceHashMap<>();
|
||||
private static final Map<Class<?>, Boolean> supportsCache = new ConcurrentHashMap<>();
|
||||
|
||||
static {
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ public class TypeCollector {
|
||||
|
||||
static class InspectionCache {
|
||||
|
||||
private final Map<String, ResolvableType> mutableCache = new LinkedHashMap<>();
|
||||
private final Map<String, ResolvableType> mutableCache = new HashMap<>();
|
||||
|
||||
public void add(ResolvableType resolvableType) {
|
||||
mutableCache.put(resolvableType.toString(), resolvableType);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.web;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
@@ -33,7 +34,6 @@ import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
|
||||
@@ -52,7 +52,7 @@ public class ProjectingJackson2HttpMessageConverter extends MappingJackson2HttpM
|
||||
implements BeanClassLoaderAware, BeanFactoryAware {
|
||||
|
||||
private final SpelAwareProxyProjectionFactory projectionFactory;
|
||||
private final Map<Class<?>, Boolean> supportedTypesCache = new ConcurrentReferenceHashMap<>();
|
||||
private final Map<Class<?>, Boolean> supportedTypesCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Creates a new {@link ProjectingJackson2HttpMessageConverter} using a default {@link ObjectMapper}.
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
@@ -31,8 +32,6 @@ import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xmlbeam.XBProjector;
|
||||
import org.xmlbeam.config.DefaultXMLFactoriesConfig;
|
||||
@@ -49,7 +48,7 @@ import org.xmlbeam.config.DefaultXMLFactoriesConfig;
|
||||
public class XmlBeamHttpMessageConverter extends AbstractHttpMessageConverter<Object> {
|
||||
|
||||
private final XBProjector projectionFactory;
|
||||
private final Map<Class<?>, Boolean> supportedTypesCache = new ConcurrentReferenceHashMap<>();
|
||||
private final Map<Class<?>, Boolean> supportedTypesCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Creates a new {@link XmlBeamHttpMessageConverter}.
|
||||
|
||||
Reference in New Issue
Block a user