Skip to content

Commit 98be36a

Browse files
committed
Extended default collection size for common per-bean caches
Issue: SPR-13621
1 parent 7b711c4 commit 98be36a

File tree

10 files changed

+16
-15
lines changed

10 files changed

+16
-15
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
3737

3838
protected boolean beforeExistingAdvisors = false;
3939

40-
private final Map<Class<?>, Boolean> eligibleBeans = new ConcurrentHashMap<Class<?>, Boolean>(64);
40+
private final Map<Class<?>, Boolean> eligibleBeans = new ConcurrentHashMap<Class<?>, Boolean>(256);
4141

4242

4343
/**

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
129129
private ConfigurableListableBeanFactory beanFactory;
130130

131131
private final Set<String> lookupMethodsChecked =
132-
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(64));
132+
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(256));
133133

134134
private final Map<Class<?>, Constructor<?>[]> candidateConstructorsCache =
135-
new ConcurrentHashMap<Class<?>, Constructor<?>[]>(64);
135+
new ConcurrentHashMap<Class<?>, Constructor<?>[]>(256);
136136

137137
private final Map<String, InjectionMetadata> injectionMetadataCache =
138-
new ConcurrentHashMap<String, InjectionMetadata>(64);
138+
new ConcurrentHashMap<String, InjectionMetadata>(256);
139139

140140

141141
/**

spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class InitDestroyAnnotationBeanPostProcessor
8383
private int order = Ordered.LOWEST_PRECEDENCE;
8484

8585
private transient final Map<Class<?>, LifecycleMetadata> lifecycleMetadataCache =
86-
new ConcurrentHashMap<Class<?>, LifecycleMetadata>(64);
86+
new ConcurrentHashMap<Class<?>, LifecycleMetadata>(256);
8787

8888

8989
/**

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
150150

151151
/** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */
152152
private final ConcurrentMap<Class<?>, PropertyDescriptor[]> filteredPropertyDescriptorsCache =
153-
new ConcurrentHashMap<Class<?>, PropertyDescriptor[]>(64);
153+
new ConcurrentHashMap<Class<?>, PropertyDescriptor[]>(256);
154154

155155

156156
/**

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
161161

162162
/** Map from bean name to merged RootBeanDefinition */
163163
private final Map<String, RootBeanDefinition> mergedBeanDefinitions =
164-
new ConcurrentHashMap<String, RootBeanDefinition>(64);
164+
new ConcurrentHashMap<String, RootBeanDefinition>(256);
165165

166166
/** Names of beans that have already been created at least once */
167-
private final Set<String> alreadyCreated = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(64));
167+
private final Set<String> alreadyCreated =
168+
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(256));
168169

169170
/** Names of beans that are currently in creation */
170171
private final ThreadLocal<Object> prototypesCurrentlyInCreation =

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
158158
private final Map<Class<?>, Object> resolvableDependencies = new ConcurrentHashMap<Class<?>, Object>(16);
159159

160160
/** Map of bean definition objects, keyed by bean name */
161-
private final Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<String, BeanDefinition>(64);
161+
private final Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<String, BeanDefinition>(256);
162162

163163
/** Map of singleton and non-singleton bean names, keyed by dependency type */
164164
private final Map<Class<?>, String[]> allBeanNamesByType = new ConcurrentHashMap<Class<?>, String[]>(64);
@@ -167,7 +167,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
167167
private final Map<Class<?>, String[]> singletonBeanNamesByType = new ConcurrentHashMap<Class<?>, String[]>(64);
168168

169169
/** List of bean definition names, in registration order */
170-
private volatile List<String> beanDefinitionNames = new ArrayList<String>(64);
170+
private volatile List<String> beanDefinitionNames = new ArrayList<String>(256);
171171

172172
/** List of names of manually registered singletons, in registration order */
173173
private volatile Set<String> manualSingletonNames = new LinkedHashSet<String>(16);

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
8383
protected final Log logger = LogFactory.getLog(getClass());
8484

8585
/** Cache of singleton objects: bean name --> bean instance */
86-
private final Map<String, Object> singletonObjects = new ConcurrentHashMap<String, Object>(64);
86+
private final Map<String, Object> singletonObjects = new ConcurrentHashMap<String, Object>(256);
8787

8888
/** Cache of singleton factories: bean name --> ObjectFactory */
8989
private final Map<String, ObjectFactory<?>> singletonFactories = new HashMap<String, ObjectFactory<?>>(16);
@@ -92,7 +92,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
9292
private final Map<String, Object> earlySingletonObjects = new HashMap<String, Object>(16);
9393

9494
/** Set of registered singletons, containing the bean names in registration order */
95-
private final Set<String> registeredSingletons = new LinkedHashSet<String>(64);
95+
private final Set<String> registeredSingletons = new LinkedHashSet<String>(256);
9696

9797
/** Names of beans that are currently in creation */
9898
private final Set<String> singletonsCurrentlyInCreation =

spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
179179
private transient BeanFactory beanFactory;
180180

181181
private transient final Map<String, InjectionMetadata> injectionMetadataCache =
182-
new ConcurrentHashMap<String, InjectionMetadata>(64);
182+
new ConcurrentHashMap<String, InjectionMetadata>(256);
183183

184184

185185
/**

spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ private static class ApplicationListenerDetector implements MergedBeanDefinition
353353

354354
private final AbstractApplicationContext applicationContext;
355355

356-
private final Map<String, Boolean> singletonNames = new ConcurrentHashMap<String, Boolean>(64);
356+
private final Map<String, Boolean> singletonNames = new ConcurrentHashMap<String, Boolean>(256);
357357

358358
public ApplicationListenerDetector(AbstractApplicationContext applicationContext) {
359359
this.applicationContext = applicationContext;

spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public class PersistenceAnnotationBeanPostProcessor
190190
private transient ListableBeanFactory beanFactory;
191191

192192
private transient final Map<String, InjectionMetadata> injectionMetadataCache =
193-
new ConcurrentHashMap<String, InjectionMetadata>(64);
193+
new ConcurrentHashMap<String, InjectionMetadata>(256);
194194

195195
private final Map<Object, EntityManager> extendedEntityManagersToClose =
196196
new ConcurrentHashMap<Object, EntityManager>(16);

0 commit comments

Comments
 (0)