diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java index 3a1a8575ee5..71ccb63a53b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.springframework.aop.aspectj.annotation; +import java.util.ArrayList; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -87,8 +87,8 @@ public class BeanFactoryAspectJAdvisorsBuilder { synchronized (this) { aspectNames = this.aspectBeanNames; if (aspectNames == null) { - List advisors = new LinkedList<>(); - aspectNames = new LinkedList<>(); + List advisors = new ArrayList<>(); + aspectNames = new ArrayList<>(); String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors( this.beanFactory, Object.class, true, false); for (String beanName : beanNames) { @@ -138,7 +138,7 @@ public class BeanFactoryAspectJAdvisorsBuilder { if (aspectNames.isEmpty()) { return Collections.emptyList(); } - List advisors = new LinkedList<>(); + List advisors = new ArrayList<>(); for (String aspectName : aspectNames) { List cachedAdvisors = this.advisorsCache.get(aspectName); if (cachedAdvisors != null) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java index 1b4ea1ed7c2..1d74071687e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java @@ -20,8 +20,8 @@ import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Comparator; -import java.util.LinkedList; import java.util.List; import org.aopalliance.aop.Advice; @@ -121,7 +121,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory = new LazySingletonAspectInstanceFactoryDecorator(aspectInstanceFactory); - List advisors = new LinkedList<>(); + List advisors = new ArrayList<>(); for (Method method : getAdvisorMethods(aspectClass)) { Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName); if (advisor != null) { @@ -147,7 +147,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto } private List getAdvisorMethods(Class aspectClass) { - final List methods = new LinkedList<>(); + final List methods = new ArrayList<>(); ReflectionUtils.doWithMethods(aspectClass, method -> { // Exclude pointcuts if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java index ad78b04383a..59ae03651c1 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java @@ -34,7 +34,7 @@ public class ProxyCreatorSupport extends AdvisedSupport { private AopProxyFactory aopProxyFactory; - private List listeners = new LinkedList<>(); + private final List listeners = new LinkedList<>(); /** Set to true when the first AOP proxy has been created. */ private boolean active = false; diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java index d69c6b2ff52..e18aac61531 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package org.springframework.aop.framework.autoproxy; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; @@ -78,10 +78,10 @@ public class BeanFactoryAdvisorRetrievalHelper { } } if (advisorNames.length == 0) { - return new LinkedList<>(); + return new ArrayList<>(); } - List advisors = new LinkedList<>(); + List advisors = new ArrayList<>(); for (String name : advisorNames) { if (isEligibleBean(name)) { if (this.beanFactory.isCurrentlyInCreation(name)) { diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java index d7e3665f1b6..83358da1594 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java @@ -20,8 +20,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; +import java.util.ArrayList; import java.util.LinkedHashSet; -import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -305,7 +305,7 @@ public abstract class AopUtils { if (candidateAdvisors.isEmpty()) { return candidateAdvisors; } - List eligibleAdvisors = new LinkedList<>(); + List eligibleAdvisors = new ArrayList<>(); for (Advisor candidate : candidateAdvisors) { if (candidate instanceof IntroductionAdvisor && canApply(candidate, clazz)) { eligibleAdvisors.add(candidate); diff --git a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java index 2b2b7d85ee6..4c450954fa0 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package org.springframework.aop.support; import java.io.Serializable; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedList; import java.util.List; import org.springframework.lang.Nullable; @@ -38,7 +38,7 @@ import org.springframework.util.PatternMatchUtils; @SuppressWarnings("serial") public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable { - private List mappedNames = new LinkedList<>(); + private List mappedNames = new ArrayList<>(); /** @@ -55,11 +55,8 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme * Matching will be the union of all these; if any match, * the pointcut matches. */ - public void setMappedNames(@Nullable String... mappedNames) { - this.mappedNames = new LinkedList<>(); - if (mappedNames != null) { - this.mappedNames.addAll(Arrays.asList(mappedNames)); - } + public void setMappedNames(String... mappedNames) { + this.mappedNames = new ArrayList<>(Arrays.asList(mappedNames)); } /** diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 2bfa7e6a039..e7728a2d307 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,11 +41,12 @@ public class NameMatchMethodPointcutTests { protected SerializableNopInterceptor nop; + /** * Create an empty pointcut, populating instance variables. */ @Before - public void setUp() { + public void setup() { ProxyFactory pf = new ProxyFactory(new SerializablePerson()); nop = new SerializableNopInterceptor(); pc = new NameMatchMethodPointcut(); @@ -53,6 +54,7 @@ public class NameMatchMethodPointcutTests { proxied = (Person) pf.getProxy(); } + @Test public void testMatchingOnly() { // Can't do exact matching through isMatch @@ -94,7 +96,7 @@ public class NameMatchMethodPointcutTests { @Test public void testSets() throws Throwable { - pc.setMappedNames(new String[] { "set*", "echo" }); + pc.setMappedNames("set*", "echo"); assertEquals(0, nop.getCount()); proxied.getName(); proxied.setName(""); @@ -116,7 +118,7 @@ public class NameMatchMethodPointcutTests { } @Test - public void testEqualsAndHashCode() throws Exception { + public void testEqualsAndHashCode() { NameMatchMethodPointcut pc1 = new NameMatchMethodPointcut(); NameMatchMethodPointcut pc2 = new NameMatchMethodPointcut(); diff --git a/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java b/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java index 71395c9328b..3f88f663457 100644 --- a/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java @@ -16,8 +16,8 @@ package org.springframework.beans; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -110,7 +110,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl } catch (PropertyAccessException ex) { if (propertyAccessExceptions == null) { - propertyAccessExceptions = new LinkedList<>(); + propertyAccessExceptions = new ArrayList<>(); } propertyAccessExceptions.add(ex); } diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java index 50ef8485041..c6ab36971f8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java @@ -27,12 +27,12 @@ import java.net.URL; import java.nio.charset.Charset; import java.nio.file.Path; import java.time.ZoneId; +import java.util.ArrayList; import java.util.Collection; import java.util.Currency; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -318,7 +318,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { // Check property-specific editor first. PropertyEditor editor = getCustomEditor(propertyPath, requiredType); if (editor == null) { - List strippedPaths = new LinkedList<>(); + List strippedPaths = new ArrayList<>(); addStrippedPropertyPaths(strippedPaths, "", propertyPath); for (Iterator it = strippedPaths.iterator(); it.hasNext() && editor == null;) { String strippedPath = it.next(); @@ -438,7 +438,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { if (this.customEditorsForPath != null) { CustomEditorHolder editorHolder = this.customEditorsForPath.get(propertyName); if (editorHolder == null) { - List strippedPaths = new LinkedList<>(); + List strippedPaths = new ArrayList<>(); addStrippedPropertyPaths(strippedPaths, "", propertyName); for (Iterator it = strippedPaths.iterator(); it.hasNext() && editorHolder == null;) { String strippedName = it.next(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java index 4b98aaddd98..677ca28022a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory; import java.io.PrintStream; import java.io.PrintWriter; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.springframework.beans.FatalBeanException; @@ -141,7 +141,7 @@ public class BeanCreationException extends FatalBeanException { */ public void addRelatedCause(Throwable ex) { if (this.relatedCauses == null) { - this.relatedCauses = new LinkedList<>(); + this.relatedCauses = new ArrayList<>(); } this.relatedCauses.add(ex); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index d052f4ed85c..94507c8b982 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -430,11 +429,11 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean } private InjectionMetadata buildAutowiringMetadata(final Class clazz) { - LinkedList elements = new LinkedList<>(); + List elements = new ArrayList<>(); Class targetClass = clazz; do { - final LinkedList currElements = new LinkedList<>(); + final List currElements = new ArrayList<>(); ReflectionUtils.doWithLocalFields(targetClass, field -> { AnnotationAttributes ann = findAutowiredAnnotation(field); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java index d8aa005b7b2..ead10fac887 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java @@ -23,9 +23,10 @@ import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; -import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -196,13 +197,13 @@ public class InitDestroyAnnotationBeanPostProcessor private LifecycleMetadata buildLifecycleMetadata(final Class clazz) { final boolean debug = logger.isDebugEnabled(); - LinkedList initMethods = new LinkedList<>(); - LinkedList destroyMethods = new LinkedList<>(); + List initMethods = new ArrayList<>(); + List destroyMethods = new ArrayList<>(); Class targetClass = clazz; do { - final LinkedList currInitMethods = new LinkedList<>(); - final LinkedList currDestroyMethods = new LinkedList<>(); + final List currInitMethods = new ArrayList<>(); + final List currDestroyMethods = new ArrayList<>(); ReflectionUtils.doWithLocalMethods(targetClass, method -> { if (this.initAnnotationType != null && method.isAnnotationPresent(this.initAnnotationType)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java index 43189476678..db4ae1e6c12 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ package org.springframework.beans.factory.config; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -45,7 +45,7 @@ public class ConstructorArgumentValues { private final Map indexedArgumentValues = new LinkedHashMap<>(0); - private final List genericArgumentValues = new LinkedList<>(); + private final List genericArgumentValues = new ArrayList<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java index 29d45dd4f54..9d6ff690a4c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.parsing; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.springframework.lang.Nullable; @@ -38,7 +38,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition { @Nullable private final Object source; - private final List nestedComponents = new LinkedList<>(); + private final List nestedComponents = new ArrayList<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index c7988000108..27a59c67a32 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -30,7 +30,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -1518,7 +1517,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @see #isExcludedFromDependencyCheck */ protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw) { - List pds = new LinkedList<>(Arrays.asList(bw.getPropertyDescriptors())); + List pds = new ArrayList<>(Arrays.asList(bw.getPropertyDescriptors())); pds.removeIf(this::isExcludedFromDependencyCheck); return pds.toArray(new PropertyDescriptor[0]); } diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java index 0250967f391..50be8384761 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java @@ -20,7 +20,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; @@ -285,7 +284,7 @@ public class FreeMarkerConfigurationFactory { config.setDefaultEncoding(this.defaultEncoding); } - List templateLoaders = new LinkedList<>(this.templateLoaders); + List templateLoaders = new ArrayList<>(this.templateLoaders); // Register template loaders that are supposed to kick in early. if (this.preTemplateLoaders != null) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java index bc8fdefdc57..c650d460cbd 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java @@ -28,10 +28,11 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; -import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -350,12 +351,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean } private InjectionMetadata buildResourceMetadata(final Class clazz) { - LinkedList elements = new LinkedList<>(); + List elements = new ArrayList<>(); Class targetClass = clazz; do { - final LinkedList currElements = - new LinkedList<>(); + final List currElements = new ArrayList<>(); ReflectionUtils.doWithLocalFields(targetClass, field -> { if (webServiceRefClass != null && field.isAnnotationPresent(webServiceRefClass)) { diff --git a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java index 477d1a86a1d..73fa12f2942 100644 --- a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java +++ b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,10 @@ package org.springframework.context.event; +import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; -import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -213,7 +214,7 @@ public abstract class AbstractApplicationEventMulticaster private Collection> retrieveApplicationListeners( ResolvableType eventType, @Nullable Class sourceType, @Nullable ListenerRetriever retriever) { - LinkedList> allListeners = new LinkedList<>(); + List> allListeners = new ArrayList<>(); Set> listeners; Set listenerBeans; synchronized (this.retrievalMutex) { @@ -368,10 +369,9 @@ public abstract class AbstractApplicationEventMulticaster } public Collection> getApplicationListeners() { - LinkedList> allListeners = new LinkedList<>(); - for (ApplicationListener listener : this.applicationListeners) { - allListeners.add(listener); - } + List> allListeners = new ArrayList<>( + this.applicationListeners.size() + this.applicationListenerBeans.size()); + allListeners.addAll(this.applicationListeners); if (!this.applicationListenerBeans.isEmpty()) { BeanFactory beanFactory = getBeanFactory(); for (String listenerBeanName : this.applicationListenerBeans) { diff --git a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java index a021d30bd06..2d992a8393a 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java +++ b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -61,8 +60,8 @@ final class PostProcessorRegistrationDelegate { if (beanFactory instanceof BeanDefinitionRegistry) { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; - List regularPostProcessors = new LinkedList<>(); - List registryProcessors = new LinkedList<>(); + List regularPostProcessors = new ArrayList<>(); + List registryProcessors = new ArrayList<>(); for (BeanFactoryPostProcessor postProcessor : beanFactoryPostProcessors) { if (postProcessor instanceof BeanDefinitionRegistryPostProcessor) { diff --git a/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java b/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java index 9a50606e0cc..246749650ed 100644 --- a/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java +++ b/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java @@ -17,8 +17,8 @@ package org.springframework.expression.common; import java.util.ArrayDeque; +import java.util.ArrayList; import java.util.Deque; -import java.util.LinkedList; import java.util.List; import org.springframework.expression.Expression; @@ -87,7 +87,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser * @throws ParseException when the expressions cannot be parsed */ private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException { - List expressions = new LinkedList<>(); + List expressions = new ArrayList<>(); String prefix = context.getExpressionPrefix(); String suffix = context.getExpressionSuffix(); int startIdx = 0; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java b/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java index 42f2e3d3367..28f4cfd6b6b 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java @@ -20,7 +20,6 @@ import java.util.ArrayDeque; import java.util.Collections; import java.util.Deque; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -65,7 +64,7 @@ public class ExpressionState { private Deque contextObjects; @Nullable - private LinkedList variableScopes; + private Deque variableScopes; // When entering a new scope there is a new base object which should be used // for '#this' references (or to act as a target for unqualified references). @@ -215,7 +214,7 @@ public class ExpressionState { private Deque initVariableScopes() { if (this.variableScopes == null) { - this.variableScopes = new LinkedList<>(); + this.variableScopes = new ArrayDeque<>(); // top-level empty variable scope this.variableScopes.add(new VariableScope()); } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java index f80a82696d6..9b7ac3d4885 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.expression.spel.ast; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import org.springframework.expression.PropertyAccessor; @@ -68,7 +67,7 @@ public abstract class AstUtils { } } } - List resolvers = new LinkedList<>(); + List resolvers = new ArrayList<>(specificAccessors.size() + generalAccessors.size()); resolvers.addAll(specificAccessors); resolvers.addAll(generalAccessors); return resolvers; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java index 05e8e219663..73568fc83e2 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java @@ -20,7 +20,6 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; import java.util.Deque; -import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; @@ -724,7 +723,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { * TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c) */ private SpelNodeImpl eatPossiblyQualifiedId() { - LinkedList qualifiedIdPieces = new LinkedList<>(); + Deque qualifiedIdPieces = new ArrayDeque<>(); Token node = peekToken(); while (isValidQualifiedId(node)) { nextToken(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java index 7c0d9518f1a..50e471bb0dc 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java @@ -22,7 +22,7 @@ import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; @@ -460,7 +460,7 @@ public abstract class ScriptUtils { separator = FALLBACK_STATEMENT_SEPARATOR; } - List statements = new LinkedList<>(); + List statements = new ArrayList<>(); splitSqlScript(resource, script, separator, commentPrefix, blockCommentStartDelimiter, blockCommentEndDelimiter, statements); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java index 5c4645c8b79..58b76ec2cef 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java @@ -18,9 +18,10 @@ package org.springframework.jdbc.object; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Deque; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import javax.sql.DataSource; @@ -55,7 +56,7 @@ public class BatchSqlUpdate extends SqlUpdate { private boolean trackRowsAffected = true; - private final LinkedList parameterQueue = new LinkedList<>(); + private final Deque parameterQueue = new ArrayDeque<>(); private final List rowsAffected = new ArrayList<>(); diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java b/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java index 836ddf7066f..51f88865731 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java @@ -22,7 +22,9 @@ import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.ArrayList; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; @@ -405,7 +407,7 @@ public class PersistenceAnnotationBeanPostProcessor } private InjectionMetadata buildPersistenceMetadata(final Class clazz) { - LinkedList elements = new LinkedList<>(); + List elements = new ArrayList<>(); Class targetClass = clazz; do { diff --git a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java index 7bf28fd4309..fa76e1a022f 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java +++ b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java @@ -18,7 +18,6 @@ package org.springframework.web.accept; import java.util.ArrayList; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -46,7 +45,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten private final MultiValueMap fileExtensions = new LinkedMultiValueMap<>(); - private final List allFileExtensions = new LinkedList<>(); + private final List allFileExtensions = new ArrayList<>(); /**