Browse Source

Prefer ArrayList/ArrayDeque over LinkedList for multi-element holders

LinkedList remains in place where a List is likely to remain empty or single-element (in order to avoid unused capacity).

Issue: SPR-17037

(cherry picked from commit 9c08a48)
pull/1916/head
Juergen Hoeller 8 years ago
parent
commit
11fc086309
  1. 10
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java
  2. 6
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
  3. 4
      spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java
  4. 8
      spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java
  5. 4
      spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java
  6. 13
      spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java
  7. 10
      spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java
  8. 4
      spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java
  9. 8
      spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java
  10. 4
      spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java
  11. 11
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
  12. 15
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java
  13. 6
      spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java
  14. 4
      spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java
  15. 3
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
  16. 5
      spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java
  17. 31
      spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
  18. 14
      spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
  19. 10
      spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java
  20. 4
      spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java
  21. 5
      spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java
  22. 5
      spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java
  23. 5
      spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java
  24. 6
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java
  25. 23
      spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java
  26. 23
      spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java
  27. 3
      spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java

10
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.springframework.aop.aspectj.annotation; package org.springframework.aop.aspectj.annotation;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -87,8 +87,8 @@ public class BeanFactoryAspectJAdvisorsBuilder {
synchronized (this) { synchronized (this) {
aspectNames = this.aspectBeanNames; aspectNames = this.aspectBeanNames;
if (aspectNames == null) { if (aspectNames == null) {
List<Advisor> advisors = new LinkedList<>(); List<Advisor> advisors = new ArrayList<>();
aspectNames = new LinkedList<>(); aspectNames = new ArrayList<>();
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors( String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
this.beanFactory, Object.class, true, false); this.beanFactory, Object.class, true, false);
for (String beanName : beanNames) { for (String beanName : beanNames) {
@ -138,7 +138,7 @@ public class BeanFactoryAspectJAdvisorsBuilder {
if (aspectNames.isEmpty()) { if (aspectNames.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<Advisor> advisors = new LinkedList<>(); List<Advisor> advisors = new ArrayList<>();
for (String aspectName : aspectNames) { for (String aspectName : aspectNames) {
List<Advisor> cachedAdvisors = this.advisorsCache.get(aspectName); List<Advisor> cachedAdvisors = this.advisorsCache.get(aspectName);
if (cachedAdvisors != null) { if (cachedAdvisors != null) {

6
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.annotation.Annotation;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.aopalliance.aop.Advice; import org.aopalliance.aop.Advice;
@ -121,7 +121,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory = MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
new LazySingletonAspectInstanceFactoryDecorator(aspectInstanceFactory); new LazySingletonAspectInstanceFactoryDecorator(aspectInstanceFactory);
List<Advisor> advisors = new LinkedList<>(); List<Advisor> advisors = new ArrayList<>();
for (Method method : getAdvisorMethods(aspectClass)) { for (Method method : getAdvisorMethods(aspectClass)) {
Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName); Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
if (advisor != null) { if (advisor != null) {
@ -147,7 +147,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
} }
private List<Method> getAdvisorMethods(Class<?> aspectClass) { private List<Method> getAdvisorMethods(Class<?> aspectClass) {
final List<Method> methods = new LinkedList<>(); final List<Method> methods = new ArrayList<>();
ReflectionUtils.doWithMethods(aspectClass, method -> { ReflectionUtils.doWithMethods(aspectClass, method -> {
// Exclude pointcuts // Exclude pointcuts
if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) { if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {

4
spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ public class ProxyCreatorSupport extends AdvisedSupport {
private AopProxyFactory aopProxyFactory; private AopProxyFactory aopProxyFactory;
private List<AdvisedSupportListener> listeners = new LinkedList<>(); private final List<AdvisedSupportListener> listeners = new LinkedList<>();
/** Set to true when the first AOP proxy has been created */ /** Set to true when the first AOP proxy has been created */
private boolean active = false; private boolean active = false;

8
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.aop.framework.autoproxy; package org.springframework.aop.framework.autoproxy;
import java.util.LinkedList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -78,10 +78,10 @@ public class BeanFactoryAdvisorRetrievalHelper {
} }
} }
if (advisorNames.length == 0) { if (advisorNames.length == 0) {
return new LinkedList<>(); return new ArrayList<>();
} }
List<Advisor> advisors = new LinkedList<>(); List<Advisor> advisors = new ArrayList<>();
for (String name : advisorNames) { for (String name : advisorNames) {
if (isEligibleBean(name)) { if (isEligibleBean(name)) {
if (this.beanFactory.isCurrentlyInCreation(name)) { if (this.beanFactory.isCurrentlyInCreation(name)) {

4
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.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -305,7 +305,7 @@ public abstract class AopUtils {
if (candidateAdvisors.isEmpty()) { if (candidateAdvisors.isEmpty()) {
return candidateAdvisors; return candidateAdvisors;
} }
List<Advisor> eligibleAdvisors = new LinkedList<>(); List<Advisor> eligibleAdvisors = new ArrayList<>();
for (Advisor candidate : candidateAdvisors) { for (Advisor candidate : candidateAdvisors) {
if (candidate instanceof IntroductionAdvisor && canApply(candidate, clazz)) { if (candidate instanceof IntroductionAdvisor && canApply(candidate, clazz)) {
eligibleAdvisors.add(candidate); eligibleAdvisors.add(candidate);

13
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
@ -38,7 +38,7 @@ import org.springframework.util.PatternMatchUtils;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable { public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable {
private List<String> mappedNames = new LinkedList<>(); private List<String> mappedNames = new ArrayList<>();
/** /**
@ -55,11 +55,8 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
* Matching will be the union of all these; if any match, * Matching will be the union of all these; if any match,
* the pointcut matches. * the pointcut matches.
*/ */
public void setMappedNames(@Nullable String... mappedNames) { public void setMappedNames(String... mappedNames) {
this.mappedNames = new LinkedList<>(); this.mappedNames = new ArrayList<>(Arrays.asList(mappedNames));
if (mappedNames != null) {
this.mappedNames.addAll(Arrays.asList(mappedNames));
}
} }
/** /**

10
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,11 +41,12 @@ public class NameMatchMethodPointcutTests {
protected SerializableNopInterceptor nop; protected SerializableNopInterceptor nop;
/** /**
* Create an empty pointcut, populating instance variables. * Create an empty pointcut, populating instance variables.
*/ */
@Before @Before
public void setUp() { public void setup() {
ProxyFactory pf = new ProxyFactory(new SerializablePerson()); ProxyFactory pf = new ProxyFactory(new SerializablePerson());
nop = new SerializableNopInterceptor(); nop = new SerializableNopInterceptor();
pc = new NameMatchMethodPointcut(); pc = new NameMatchMethodPointcut();
@ -53,6 +54,7 @@ public class NameMatchMethodPointcutTests {
proxied = (Person) pf.getProxy(); proxied = (Person) pf.getProxy();
} }
@Test @Test
public void testMatchingOnly() { public void testMatchingOnly() {
// Can't do exact matching through isMatch // Can't do exact matching through isMatch
@ -94,7 +96,7 @@ public class NameMatchMethodPointcutTests {
@Test @Test
public void testSets() throws Throwable { public void testSets() throws Throwable {
pc.setMappedNames(new String[] { "set*", "echo" }); pc.setMappedNames("set*", "echo");
assertEquals(0, nop.getCount()); assertEquals(0, nop.getCount());
proxied.getName(); proxied.getName();
proxied.setName(""); proxied.setName("");
@ -116,7 +118,7 @@ public class NameMatchMethodPointcutTests {
} }
@Test @Test
public void testEqualsAndHashCode() throws Exception { public void testEqualsAndHashCode() {
NameMatchMethodPointcut pc1 = new NameMatchMethodPointcut(); NameMatchMethodPointcut pc1 = new NameMatchMethodPointcut();
NameMatchMethodPointcut pc2 = new NameMatchMethodPointcut(); NameMatchMethodPointcut pc2 = new NameMatchMethodPointcut();

4
spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java

@ -16,8 +16,8 @@
package org.springframework.beans; package org.springframework.beans;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -110,7 +110,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl
} }
catch (PropertyAccessException ex) { catch (PropertyAccessException ex) {
if (propertyAccessExceptions == null) { if (propertyAccessExceptions == null) {
propertyAccessExceptions = new LinkedList<>(); propertyAccessExceptions = new ArrayList<>();
} }
propertyAccessExceptions.add(ex); propertyAccessExceptions.add(ex);
} }

8
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.charset.Charset;
import java.nio.file.Path; import java.nio.file.Path;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Currency; import java.util.Currency;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -318,7 +318,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
// Check property-specific editor first. // Check property-specific editor first.
PropertyEditor editor = getCustomEditor(propertyPath, requiredType); PropertyEditor editor = getCustomEditor(propertyPath, requiredType);
if (editor == null) { if (editor == null) {
List<String> strippedPaths = new LinkedList<>(); List<String> strippedPaths = new ArrayList<>();
addStrippedPropertyPaths(strippedPaths, "", propertyPath); addStrippedPropertyPaths(strippedPaths, "", propertyPath);
for (Iterator<String> it = strippedPaths.iterator(); it.hasNext() && editor == null;) { for (Iterator<String> it = strippedPaths.iterator(); it.hasNext() && editor == null;) {
String strippedPath = it.next(); String strippedPath = it.next();
@ -438,7 +438,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
if (this.customEditorsForPath != null) { if (this.customEditorsForPath != null) {
CustomEditorHolder editorHolder = this.customEditorsForPath.get(propertyName); CustomEditorHolder editorHolder = this.customEditorsForPath.get(propertyName);
if (editorHolder == null) { if (editorHolder == null) {
List<String> strippedPaths = new LinkedList<>(); List<String> strippedPaths = new ArrayList<>();
addStrippedPropertyPaths(strippedPaths, "", propertyName); addStrippedPropertyPaths(strippedPaths, "", propertyName);
for (Iterator<String> it = strippedPaths.iterator(); it.hasNext() && editorHolder == null;) { for (Iterator<String> it = strippedPaths.iterator(); it.hasNext() && editorHolder == null;) {
String strippedName = it.next(); String strippedName = it.next();
@ -517,7 +517,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
* Holder for a registered custom editor with property name. * Holder for a registered custom editor with property name.
* Keeps the PropertyEditor itself plus the type it was registered for. * Keeps the PropertyEditor itself plus the type it was registered for.
*/ */
private static class CustomEditorHolder { private static final class CustomEditorHolder {
private final PropertyEditor propertyEditor; private final PropertyEditor propertyEditor;

4
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.PrintStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.LinkedList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.beans.FatalBeanException; import org.springframework.beans.FatalBeanException;
@ -135,7 +135,7 @@ public class BeanCreationException extends FatalBeanException {
*/ */
public void addRelatedCause(Throwable ex) { public void addRelatedCause(Throwable ex) {
if (this.relatedCauses == null) { if (this.relatedCauses == null) {
this.relatedCauses = new LinkedList<>(); this.relatedCauses = new ArrayList<>();
} }
this.relatedCauses.add(ex); this.relatedCauses.add(ex);
} }

11
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.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -245,10 +244,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
ReflectionUtils.doWithMethods(beanClass, method -> { ReflectionUtils.doWithMethods(beanClass, method -> {
Lookup lookup = method.getAnnotation(Lookup.class); Lookup lookup = method.getAnnotation(Lookup.class);
if (lookup != null) { if (lookup != null) {
Assert.state(beanFactory != null, "No BeanFactory available"); Assert.state(this.beanFactory != null, "No BeanFactory available");
LookupOverride override = new LookupOverride(method, lookup.value()); LookupOverride override = new LookupOverride(method, lookup.value());
try { try {
RootBeanDefinition mbd = (RootBeanDefinition) beanFactory.getMergedBeanDefinition(beanName); RootBeanDefinition mbd = (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(beanName);
mbd.getMethodOverrides().addOverride(override); mbd.getMethodOverrides().addOverride(override);
} }
catch (NoSuchBeanDefinitionException ex) { catch (NoSuchBeanDefinitionException ex) {
@ -424,11 +423,11 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
} }
private InjectionMetadata buildAutowiringMetadata(final Class<?> clazz) { private InjectionMetadata buildAutowiringMetadata(final Class<?> clazz) {
LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<>(); List<InjectionMetadata.InjectedElement> elements = new ArrayList<>();
Class<?> targetClass = clazz; Class<?> targetClass = clazz;
do { do {
final LinkedList<InjectionMetadata.InjectedElement> currElements = new LinkedList<>(); final List<InjectionMetadata.InjectedElement> currElements = new ArrayList<>();
ReflectionUtils.doWithLocalFields(targetClass, field -> { ReflectionUtils.doWithLocalFields(targetClass, field -> {
AnnotationAttributes ann = findAutowiredAnnotation(field); AnnotationAttributes ann = findAutowiredAnnotation(field);
@ -541,7 +540,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
private Object resolvedCachedArgument(@Nullable String beanName, @Nullable Object cachedArgument) { private Object resolvedCachedArgument(@Nullable String beanName, @Nullable Object cachedArgument) {
if (cachedArgument instanceof DependencyDescriptor) { if (cachedArgument instanceof DependencyDescriptor) {
DependencyDescriptor descriptor = (DependencyDescriptor) cachedArgument; DependencyDescriptor descriptor = (DependencyDescriptor) cachedArgument;
Assert.state(beanFactory != null, "No BeanFactory available"); Assert.state(this.beanFactory != null, "No BeanFactory available");
return this.beanFactory.resolveDependency(descriptor, beanName, null, null); return this.beanFactory.resolveDependency(descriptor, beanName, null, null);
} }
else { else {

15
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.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -196,23 +197,23 @@ public class InitDestroyAnnotationBeanPostProcessor
private LifecycleMetadata buildLifecycleMetadata(final Class<?> clazz) { private LifecycleMetadata buildLifecycleMetadata(final Class<?> clazz) {
final boolean debug = logger.isDebugEnabled(); final boolean debug = logger.isDebugEnabled();
LinkedList<LifecycleElement> initMethods = new LinkedList<>(); List<LifecycleElement> initMethods = new ArrayList<>();
LinkedList<LifecycleElement> destroyMethods = new LinkedList<>(); List<LifecycleElement> destroyMethods = new ArrayList<>();
Class<?> targetClass = clazz; Class<?> targetClass = clazz;
do { do {
final LinkedList<LifecycleElement> currInitMethods = new LinkedList<>(); final List<LifecycleElement> currInitMethods = new ArrayList<>();
final LinkedList<LifecycleElement> currDestroyMethods = new LinkedList<>(); final List<LifecycleElement> currDestroyMethods = new ArrayList<>();
ReflectionUtils.doWithLocalMethods(targetClass, method -> { ReflectionUtils.doWithLocalMethods(targetClass, method -> {
if (initAnnotationType != null && method.isAnnotationPresent(initAnnotationType)) { if (this.initAnnotationType != null && method.isAnnotationPresent(this.initAnnotationType)) {
LifecycleElement element = new LifecycleElement(method); LifecycleElement element = new LifecycleElement(method);
currInitMethods.add(element); currInitMethods.add(element);
if (debug) { if (debug) {
logger.debug("Found init method on class [" + clazz.getName() + "]: " + method); logger.debug("Found init method on class [" + clazz.getName() + "]: " + method);
} }
} }
if (destroyAnnotationType != null && method.isAnnotationPresent(destroyAnnotationType)) { if (this.destroyAnnotationType != null && method.isAnnotationPresent(this.destroyAnnotationType)) {
currDestroyMethods.add(new LifecycleElement(method)); currDestroyMethods.add(new LifecycleElement(method));
if (debug) { if (debug) {
logger.debug("Found destroy method on class [" + clazz.getName() + "]: " + method); logger.debug("Found destroy method on class [" + clazz.getName() + "]: " + method);

6
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,10 +16,10 @@
package org.springframework.beans.factory.config; package org.springframework.beans.factory.config;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -45,7 +45,7 @@ public class ConstructorArgumentValues {
private final Map<Integer, ValueHolder> indexedArgumentValues = new LinkedHashMap<>(0); private final Map<Integer, ValueHolder> indexedArgumentValues = new LinkedHashMap<>(0);
private final List<ValueHolder> genericArgumentValues = new LinkedList<>(); private final List<ValueHolder> genericArgumentValues = new ArrayList<>();
/** /**

4
spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java

@ -16,7 +16,7 @@
package org.springframework.beans.factory.parsing; package org.springframework.beans.factory.parsing;
import java.util.LinkedList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
@ -38,7 +38,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition {
@Nullable @Nullable
private final Object source; private final Object source;
private final List<ComponentDefinition> nestedComponents = new LinkedList<>(); private final List<ComponentDefinition> nestedComponents = new ArrayList<>();
/** /**

3
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.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -1495,7 +1494,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #isExcludedFromDependencyCheck * @see #isExcludedFromDependencyCheck
*/ */
protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw) { protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw) {
List<PropertyDescriptor> pds = new LinkedList<>(Arrays.asList(bw.getPropertyDescriptors())); List<PropertyDescriptor> pds = new ArrayList<>(Arrays.asList(bw.getPropertyDescriptors()));
pds.removeIf(this::isExcludedFromDependencyCheck); pds.removeIf(this::isExcludedFromDependencyCheck);
return pds.toArray(new PropertyDescriptor[0]); return pds.toArray(new PropertyDescriptor[0]);
} }

5
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.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -113,7 +112,7 @@ public class FreeMarkerConfigurationFactory {
* @see #setTemplateLoaderPath * @see #setTemplateLoaderPath
*/ */
public void setConfigLocation(Resource resource) { public void setConfigLocation(Resource resource) {
configLocation = resource; this.configLocation = resource;
} }
/** /**
@ -285,7 +284,7 @@ public class FreeMarkerConfigurationFactory {
config.setDefaultEncoding(this.defaultEncoding); config.setDefaultEncoding(this.defaultEncoding);
} }
List<TemplateLoader> templateLoaders = new LinkedList<>(this.templateLoaders); List<TemplateLoader> templateLoaders = new ArrayList<>(this.templateLoaders);
// Register template loaders that are supposed to kick in early. // Register template loaders that are supposed to kick in early.
if (this.preTemplateLoaders != null) { if (this.preTemplateLoaders != null) {

31
spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,10 +28,11 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -47,7 +48,6 @@ import javax.xml.ws.WebServiceRef;
import org.springframework.aop.TargetSource; import org.springframework.aop.TargetSource;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues; import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
@ -300,18 +300,18 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
} }
@Override @Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException { public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
return null; return null;
} }
@Override @Override
public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { public boolean postProcessAfterInstantiation(Object bean, String beanName) {
return true; return true;
} }
@Override @Override
public PropertyValues postProcessPropertyValues( public PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException { PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) {
InjectionMetadata metadata = findResourceMetadata(beanName, bean.getClass(), pvs); InjectionMetadata metadata = findResourceMetadata(beanName, bean.getClass(), pvs);
try { try {
@ -345,12 +345,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
} }
private InjectionMetadata buildResourceMetadata(final Class<?> clazz) { private InjectionMetadata buildResourceMetadata(final Class<?> clazz) {
LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<>(); List<InjectionMetadata.InjectedElement> elements = new ArrayList<>();
Class<?> targetClass = clazz; Class<?> targetClass = clazz;
do { do {
final LinkedList<InjectionMetadata.InjectedElement> currElements = final List<InjectionMetadata.InjectedElement> currElements = new ArrayList<>();
new LinkedList<>();
ReflectionUtils.doWithLocalFields(targetClass, field -> { ReflectionUtils.doWithLocalFields(targetClass, field -> {
if (webServiceRefClass != null && field.isAnnotationPresent(webServiceRefClass)) { if (webServiceRefClass != null && field.isAnnotationPresent(webServiceRefClass)) {
@ -369,7 +368,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
if (Modifier.isStatic(field.getModifiers())) { if (Modifier.isStatic(field.getModifiers())) {
throw new IllegalStateException("@Resource annotation is not supported on static fields"); throw new IllegalStateException("@Resource annotation is not supported on static fields");
} }
if (!ignoredResourceTypes.contains(field.getType().getName())) { if (!this.ignoredResourceTypes.contains(field.getType().getName())) {
currElements.add(new ResourceElement(field, field, null)); currElements.add(new ResourceElement(field, field, null));
} }
} }
@ -409,7 +408,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
if (paramTypes.length != 1) { if (paramTypes.length != 1) {
throw new IllegalStateException("@Resource annotation requires a single-arg method: " + method); throw new IllegalStateException("@Resource annotation requires a single-arg method: " + method);
} }
if (!ignoredResourceTypes.contains(paramTypes[0].getName())) { if (!this.ignoredResourceTypes.contains(paramTypes[0].getName())) {
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
currElements.add(new ResourceElement(method, bridgedMethod, pd)); currElements.add(new ResourceElement(method, bridgedMethod, pd));
} }
@ -468,9 +467,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
* @param element the descriptor for the annotated field/method * @param element the descriptor for the annotated field/method
* @param requestingBeanName the name of the requesting bean * @param requestingBeanName the name of the requesting bean
* @return the resource object (never {@code null}) * @return the resource object (never {@code null})
* @throws BeansException if we failed to obtain the target resource * @throws NoSuchBeanDefinitionException if no corresponding target resource found
*/ */
protected Object getResource(LookupElement element, @Nullable String requestingBeanName) throws BeansException { protected Object getResource(LookupElement element, @Nullable String requestingBeanName)
throws NoSuchBeanDefinitionException {
if (StringUtils.hasLength(element.mappedName)) { if (StringUtils.hasLength(element.mappedName)) {
return this.jndiFactory.getBean(element.mappedName, element.lookupType); return this.jndiFactory.getBean(element.mappedName, element.lookupType);
} }
@ -491,10 +492,10 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
* @param element the descriptor for the annotated field/method * @param element the descriptor for the annotated field/method
* @param requestingBeanName the name of the requesting bean * @param requestingBeanName the name of the requesting bean
* @return the resource object (never {@code null}) * @return the resource object (never {@code null})
* @throws BeansException if we failed to obtain the target resource * @throws NoSuchBeanDefinitionException if no corresponding target resource found
*/ */
protected Object autowireResource(BeanFactory factory, LookupElement element, @Nullable String requestingBeanName) protected Object autowireResource(BeanFactory factory, LookupElement element, @Nullable String requestingBeanName)
throws BeansException { throws NoSuchBeanDefinitionException {
Object resource; Object resource;
Set<String> autowiredBeanNames; Set<String> autowiredBeanNames;

14
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,10 @@
package org.springframework.context.event; package org.springframework.context.event;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -213,7 +214,7 @@ public abstract class AbstractApplicationEventMulticaster
private Collection<ApplicationListener<?>> retrieveApplicationListeners( private Collection<ApplicationListener<?>> retrieveApplicationListeners(
ResolvableType eventType, @Nullable Class<?> sourceType, @Nullable ListenerRetriever retriever) { ResolvableType eventType, @Nullable Class<?> sourceType, @Nullable ListenerRetriever retriever) {
LinkedList<ApplicationListener<?>> allListeners = new LinkedList<>(); List<ApplicationListener<?>> allListeners = new ArrayList<>();
Set<ApplicationListener<?>> listeners; Set<ApplicationListener<?>> listeners;
Set<String> listenerBeans; Set<String> listenerBeans;
synchronized (this.retrievalMutex) { synchronized (this.retrievalMutex) {
@ -368,10 +369,9 @@ public abstract class AbstractApplicationEventMulticaster
} }
public Collection<ApplicationListener<?>> getApplicationListeners() { public Collection<ApplicationListener<?>> getApplicationListeners() {
LinkedList<ApplicationListener<?>> allListeners = new LinkedList<>(); List<ApplicationListener<?>> allListeners = new ArrayList<>(
for (ApplicationListener<?> listener : this.applicationListeners) { this.applicationListeners.size() + this.applicationListenerBeans.size());
allListeners.add(listener); allListeners.addAll(this.applicationListeners);
}
if (!this.applicationListenerBeans.isEmpty()) { if (!this.applicationListenerBeans.isEmpty()) {
BeanFactory beanFactory = getBeanFactory(); BeanFactory beanFactory = getBeanFactory();
for (String listenerBeanName : this.applicationListenerBeans) { for (String listenerBeanName : this.applicationListenerBeans) {

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

@ -18,10 +18,8 @@ package org.springframework.context.support;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -48,7 +46,7 @@ import org.springframework.lang.Nullable;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.0 * @since 4.0
*/ */
class PostProcessorRegistrationDelegate { final class PostProcessorRegistrationDelegate {
public static void invokeBeanFactoryPostProcessors( public static void invokeBeanFactoryPostProcessors(
ConfigurableListableBeanFactory beanFactory, List<BeanFactoryPostProcessor> beanFactoryPostProcessors) { ConfigurableListableBeanFactory beanFactory, List<BeanFactoryPostProcessor> beanFactoryPostProcessors) {
@ -58,8 +56,8 @@ class PostProcessorRegistrationDelegate {
if (beanFactory instanceof BeanDefinitionRegistry) { if (beanFactory instanceof BeanDefinitionRegistry) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
List<BeanFactoryPostProcessor> regularPostProcessors = new LinkedList<>(); List<BeanFactoryPostProcessor> regularPostProcessors = new ArrayList<>();
List<BeanDefinitionRegistryPostProcessor> registryProcessors = new LinkedList<>(); List<BeanDefinitionRegistryPostProcessor> registryProcessors = new ArrayList<>();
for (BeanFactoryPostProcessor postProcessor : beanFactoryPostProcessors) { for (BeanFactoryPostProcessor postProcessor : beanFactoryPostProcessors) {
if (postProcessor instanceof BeanDefinitionRegistryPostProcessor) { if (postProcessor instanceof BeanDefinitionRegistryPostProcessor) {
@ -302,7 +300,7 @@ class PostProcessorRegistrationDelegate {
* BeanPostProcessor instantiation, i.e. when a bean is not eligible for * BeanPostProcessor instantiation, i.e. when a bean is not eligible for
* getting processed by all BeanPostProcessors. * getting processed by all BeanPostProcessors.
*/ */
private static class BeanPostProcessorChecker implements BeanPostProcessor { private static final class BeanPostProcessorChecker implements BeanPostProcessor {
private static final Log logger = LogFactory.getLog(BeanPostProcessorChecker.class); private static final Log logger = LogFactory.getLog(BeanPostProcessorChecker.class);

4
spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java

@ -17,8 +17,8 @@
package org.springframework.expression.common; package org.springframework.expression.common;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque; import java.util.Deque;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.springframework.expression.Expression; import org.springframework.expression.Expression;
@ -87,7 +87,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
* @throws ParseException when the expressions cannot be parsed * @throws ParseException when the expressions cannot be parsed
*/ */
private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException { private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException {
List<Expression> expressions = new LinkedList<>(); List<Expression> expressions = new ArrayList<>();
String prefix = context.getExpressionPrefix(); String prefix = context.getExpressionPrefix();
String suffix = context.getExpressionSuffix(); String suffix = context.getExpressionSuffix();
int startIdx = 0; int startIdx = 0;

5
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.Collections;
import java.util.Deque; import java.util.Deque;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@ -65,7 +64,7 @@ public class ExpressionState {
private Deque<TypedValue> contextObjects; private Deque<TypedValue> contextObjects;
@Nullable @Nullable
private LinkedList<VariableScope> variableScopes; private Deque<VariableScope> variableScopes;
// When entering a new scope there is a new base object which should be used // 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). // for '#this' references (or to act as a target for unqualified references).
@ -215,7 +214,7 @@ public class ExpressionState {
private Deque<VariableScope> initVariableScopes() { private Deque<VariableScope> initVariableScopes() {
if (this.variableScopes == null) { if (this.variableScopes == null) {
this.variableScopes = new LinkedList<>(); this.variableScopes = new ArrayDeque<>();
// top-level empty variable scope // top-level empty variable scope
this.variableScopes.add(new VariableScope()); this.variableScopes.add(new VariableScope());
} }

5
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.expression.spel.ast; package org.springframework.expression.spel.ast;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.springframework.expression.PropertyAccessor; import org.springframework.expression.PropertyAccessor;
@ -68,7 +67,7 @@ public abstract class AstUtils {
} }
} }
} }
List<PropertyAccessor> resolvers = new LinkedList<>(); List<PropertyAccessor> resolvers = new ArrayList<>(specificAccessors.size() + generalAccessors.size());
resolvers.addAll(specificAccessors); resolvers.addAll(specificAccessors);
resolvers.addAll(generalAccessors); resolvers.addAll(generalAccessors);
return resolvers; return resolvers;

5
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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Deque; import java.util.Deque;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -456,7 +455,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
} }
/** /**
* Used for consuming arguments for either a method or a constructor call * Used for consuming arguments for either a method or a constructor call.
*/ */
private void consumeArguments(List<SpelNodeImpl> accumulatedArguments) { private void consumeArguments(List<SpelNodeImpl> accumulatedArguments) {
Token t = peekToken(); Token t = peekToken();
@ -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) * TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c)
*/ */
private SpelNodeImpl eatPossiblyQualifiedId() { private SpelNodeImpl eatPossiblyQualifiedId() {
LinkedList<SpelNodeImpl> qualifiedIdPieces = new LinkedList<>(); Deque<SpelNodeImpl> qualifiedIdPieces = new ArrayDeque<>();
Token node = peekToken(); Token node = peekToken();
while (isValidQualifiedId(node)) { while (isValidQualifiedId(node)) {
nextToken(); nextToken();

6
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.SQLException;
import java.sql.SQLWarning; import java.sql.SQLWarning;
import java.sql.Statement; import java.sql.Statement;
import java.util.LinkedList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -339,7 +339,7 @@ public abstract class ScriptUtils {
/** /**
* Does the provided SQL script contain the specified delimiter? * Does the provided SQL script contain the specified delimiter?
* @param script the SQL script * @param script the SQL script
* @param delim String delimiting each statement - typically a ';' character * @param delim the string delimiting each statement - typically a ';' character
*/ */
public static boolean containsSqlScriptDelimiters(String script, String delim) { public static boolean containsSqlScriptDelimiters(String script, String delim) {
boolean inLiteral = false; boolean inLiteral = false;
@ -460,7 +460,7 @@ public abstract class ScriptUtils {
separator = FALLBACK_STATEMENT_SEPARATOR; separator = FALLBACK_STATEMENT_SEPARATOR;
} }
List<String> statements = new LinkedList<>(); List<String> statements = new ArrayList<>();
splitSqlScript(resource, script, separator, commentPrefix, blockCommentStartDelimiter, splitSqlScript(resource, script, separator, commentPrefix, blockCommentStartDelimiter,
blockCommentEndDelimiter, statements); blockCommentEndDelimiter, statements);

23
spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,9 +18,10 @@ package org.springframework.jdbc.object;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Deque;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -55,7 +56,7 @@ public class BatchSqlUpdate extends SqlUpdate {
private boolean trackRowsAffected = true; private boolean trackRowsAffected = true;
private final LinkedList<Object[]> parameterQueue = new LinkedList<>(); private final Deque<Object[]> parameterQueue = new ArrayDeque<>();
private final List<Integer> rowsAffected = new ArrayList<>(); private final List<Integer> rowsAffected = new ArrayList<>();
@ -72,8 +73,8 @@ public class BatchSqlUpdate extends SqlUpdate {
/** /**
* Construct an update object with a given DataSource and SQL. * Construct an update object with a given DataSource and SQL.
* @param ds DataSource to use to obtain connections * @param ds the DataSource to use to obtain connections
* @param sql SQL statement to execute * @param sql the SQL statement to execute
*/ */
public BatchSqlUpdate(DataSource ds, String sql) { public BatchSqlUpdate(DataSource ds, String sql) {
super(ds, sql); super(ds, sql);
@ -82,9 +83,9 @@ public class BatchSqlUpdate extends SqlUpdate {
/** /**
* Construct an update object with a given DataSource, SQL * Construct an update object with a given DataSource, SQL
* and anonymous parameters. * and anonymous parameters.
* @param ds DataSource to use to obtain connections * @param ds the DataSource to use to obtain connections
* @param sql SQL statement to execute * @param sql the SQL statement to execute
* @param types SQL types of the parameters, as defined in the * @param types the SQL types of the parameters, as defined in the
* {@code java.sql.Types} class * {@code java.sql.Types} class
* @see java.sql.Types * @see java.sql.Types
*/ */
@ -96,9 +97,9 @@ public class BatchSqlUpdate extends SqlUpdate {
* Construct an update object with a given DataSource, SQL, * Construct an update object with a given DataSource, SQL,
* anonymous parameters and specifying the maximum number of rows * anonymous parameters and specifying the maximum number of rows
* that may be affected. * that may be affected.
* @param ds DataSource to use to obtain connections * @param ds the DataSource to use to obtain connections
* @param sql SQL statement to execute * @param sql the SQL statement to execute
* @param types SQL types of the parameters, as defined in the * @param types the SQL types of the parameters, as defined in the
* {@code java.sql.Types} class * {@code java.sql.Types} class
* @param batchSize the number of statements that will trigger * @param batchSize the number of statements that will trigger
* an automatic intermediate flush * an automatic intermediate flush

23
spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,9 @@ import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Member; import java.lang.reflect.Member;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -35,7 +37,6 @@ import javax.persistence.PersistenceUnit;
import javax.persistence.SynchronizationType; import javax.persistence.SynchronizationType;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues; import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
@ -311,12 +312,12 @@ public class PersistenceAnnotationBeanPostProcessor
} }
public void setOrder(int order) { public void setOrder(int order) {
this.order = order; this.order = order;
} }
@Override @Override
public int getOrder() { public int getOrder() {
return this.order; return this.order;
} }
@Override @Override
@ -334,18 +335,18 @@ public class PersistenceAnnotationBeanPostProcessor
} }
@Override @Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException { public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
return null; return null;
} }
@Override @Override
public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { public boolean postProcessAfterInstantiation(Object bean, String beanName) {
return true; return true;
} }
@Override @Override
public PropertyValues postProcessPropertyValues( public PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException { PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) {
InjectionMetadata metadata = findPersistenceMetadata(beanName, bean.getClass(), pvs); InjectionMetadata metadata = findPersistenceMetadata(beanName, bean.getClass(), pvs);
try { try {
@ -358,17 +359,17 @@ public class PersistenceAnnotationBeanPostProcessor
} }
@Override @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean; return bean;
} }
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean; return bean;
} }
@Override @Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { public void postProcessBeforeDestruction(Object bean, String beanName) {
EntityManager emToClose = this.extendedEntityManagersToClose.remove(bean); EntityManager emToClose = this.extendedEntityManagersToClose.remove(bean);
EntityManagerFactoryUtils.closeEntityManager(emToClose); EntityManagerFactoryUtils.closeEntityManager(emToClose);
} }
@ -400,7 +401,7 @@ public class PersistenceAnnotationBeanPostProcessor
} }
private InjectionMetadata buildPersistenceMetadata(final Class<?> clazz) { private InjectionMetadata buildPersistenceMetadata(final Class<?> clazz) {
LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<>(); List<InjectionMetadata.InjectedElement> elements = new ArrayList<>();
Class<?> targetClass = clazz; Class<?> targetClass = clazz;
do { do {

3
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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -46,7 +45,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
private final MultiValueMap<MediaType, String> fileExtensions = new LinkedMultiValueMap<>(); private final MultiValueMap<MediaType, String> fileExtensions = new LinkedMultiValueMap<>();
private final List<String> allFileExtensions = new LinkedList<>(); private final List<String> allFileExtensions = new ArrayList<>();
/** /**

Loading…
Cancel
Save