Replace remaining usage of LinkedList with ArrayList/ArrayDeque

Closes gh-25650
This commit is contained in:
Juergen Hoeller 2020-08-26 18:32:08 +02:00
parent d198c4426f
commit 874574513c
65 changed files with 239 additions and 239 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import org.springframework.util.Assert;
@ -34,7 +34,7 @@ public class ProxyCreatorSupport extends AdvisedSupport {
private AopProxyFactory aopProxyFactory;
private final List<AdvisedSupportListener> listeners = new LinkedList<>();
private final List<AdvisedSupportListener> listeners = new ArrayList<>();
/** Set to true when the first AOP proxy has been created. */
private boolean active = false;

View File

@ -16,12 +16,12 @@
package org.springframework.beans.factory.parsing;
import java.util.LinkedList;
import java.util.ArrayDeque;
import org.springframework.lang.Nullable;
/**
* Simple {@link LinkedList}-based structure for tracking the logical position during
* Simple {@link ArrayDeque}-based structure for tracking the logical position during
* a parsing process. {@link Entry entries} are added to the LinkedList at
* each point during the parse phase in a reader-specific manner.
*
@ -30,6 +30,7 @@ import org.springframework.lang.Nullable;
* error messages.
*
* @author Rob Harrop
* @author Juergen Hoeller
* @since 2.0
*/
public final class ParseState {
@ -40,25 +41,24 @@ public final class ParseState {
private static final char TAB = '\t';
/**
* Internal {@link LinkedList} storage.
* Internal {@link ArrayDeque} storage.
*/
private final LinkedList<Entry> state;
private final ArrayDeque<Entry> state;
/**
* Create a new {@code ParseState} with an empty {@link LinkedList}.
*/
public ParseState() {
this.state = new LinkedList<>();
this.state = new ArrayDeque<>();
}
/**
* Create a new {@code ParseState} whose {@link LinkedList} is a {@link Object#clone clone}
* of that of the passed in {@code ParseState}.
*/
@SuppressWarnings("unchecked")
private ParseState(ParseState other) {
this.state = (LinkedList<Entry>) other.state.clone();
this.state = other.state.clone();
}
@ -100,15 +100,17 @@ public final class ParseState {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int x = 0; x < this.state.size(); x++) {
if (x > 0) {
int i = 0;
for (ParseState.Entry entry : this.state) {
if (i > 0) {
sb.append('\n');
for (int y = 0; y < x; y++) {
for (int j = 0; j < i; j++) {
sb.append(TAB);
}
sb.append("-> ");
}
sb.append(this.state.get(x));
sb.append(entry);
i++;
}
return sb.toString();
}
@ -118,7 +120,6 @@ public final class ParseState {
* Marker interface for entries into the {@link ParseState}.
*/
public interface Entry {
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2020 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.beans.factory.serviceloader;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
@ -35,7 +35,7 @@ public class ServiceListFactoryBean extends AbstractServiceLoaderBasedFactoryBea
@Override
protected Object getObjectToExpose(ServiceLoader<?> serviceLoader) {
List<Object> result = new LinkedList<>();
List<Object> result = new ArrayList<>();
for (Object loaderObject : serviceLoader) {
result.add(loaderObject);
}

View File

@ -24,12 +24,13 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -199,7 +200,7 @@ class ConstructorResolver {
AutowireUtils.sortConstructors(candidates);
int minTypeDiffWeight = Integer.MAX_VALUE;
Set<Constructor<?>> ambiguousConstructors = null;
LinkedList<UnsatisfiedDependencyException> causes = null;
Deque<UnsatisfiedDependencyException> causes = null;
for (Constructor<?> candidate : candidates) {
int parameterCount = candidate.getParameterCount();
@ -233,7 +234,7 @@ class ConstructorResolver {
}
// Swallow and try next constructor.
if (causes == null) {
causes = new LinkedList<>();
causes = new ArrayDeque<>(1);
}
causes.add(ex);
continue;
@ -511,7 +512,7 @@ class ConstructorResolver {
}
}
LinkedList<UnsatisfiedDependencyException> causes = null;
Deque<UnsatisfiedDependencyException> causes = null;
for (Method candidate : candidates) {
int parameterCount = candidate.getParameterCount();
@ -544,7 +545,7 @@ class ConstructorResolver {
}
// Swallow and try next overloaded factory method.
if (causes == null) {
causes = new LinkedList<>();
causes = new ArrayDeque<>(1);
}
causes.add(ex);
continue;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,7 @@
package org.springframework.beans.factory.support;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import org.springframework.lang.Nullable;
@ -39,7 +39,7 @@ public class ReplaceOverride extends MethodOverride {
private final String methodReplacerBeanName;
private List<String> typeIdentifiers = new LinkedList<>();
private final List<String> typeIdentifiers = new ArrayList<>();
/**
@ -70,6 +70,7 @@ public class ReplaceOverride extends MethodOverride {
this.typeIdentifiers.add(identifier);
}
@Override
public boolean matches(Method method) {
if (!method.getName().equals(getMethodName())) {

View File

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -36,13 +35,13 @@ import org.springframework.beans.factory.parsing.ReaderEventListener;
*/
public class CollectingReaderEventListener implements ReaderEventListener {
private final List<DefaultsDefinition> defaults = new LinkedList<>();
private final List<DefaultsDefinition> defaults = new ArrayList<>();
private final Map<String, ComponentDefinition> componentDefinitions = new LinkedHashMap<>(8);
private final Map<String, List<AliasDefinition>> aliasMap = new LinkedHashMap<>(8);
private final List<ImportDefinition> imports = new LinkedList<>();
private final List<ImportDefinition> imports = new ArrayList<>();
@Override

View File

@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -77,7 +76,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
private Float myFloat = Float.valueOf(0.0f);
private Collection<? super Object> friends = new LinkedList<>();
private Collection<? super Object> friends = new ArrayList<>();
private Set<?> someSet = new HashSet<>();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.scheduling.commonj;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import javax.naming.NamingException;
@ -62,7 +62,8 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
@Nullable
private ScheduledTimerListener[] scheduledTimerListeners;
private final List<Timer> timers = new LinkedList<>();
@Nullable
private List<Timer> timers;
/**
@ -87,6 +88,7 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
super.afterPropertiesSet();
if (this.scheduledTimerListeners != null) {
this.timers = new ArrayList<>(this.scheduledTimerListeners.length);
TimerManager timerManager = obtainTimerManager();
for (ScheduledTimerListener scheduledTask : this.scheduledTimerListeners) {
Timer timer;
@ -144,15 +146,17 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
@Override
public void destroy() {
// Cancel all registered timers.
for (Timer timer : this.timers) {
try {
timer.cancel();
}
catch (Throwable ex) {
logger.debug("Could not cancel CommonJ Timer", ex);
if (this.timers != null) {
for (Timer timer : this.timers) {
try {
timer.cancel();
}
catch (Throwable ex) {
logger.debug("Could not cancel CommonJ Timer", ex);
}
}
this.timers.clear();
}
this.timers.clear();
// Stop the TimerManager itself.
super.destroy();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,7 +18,6 @@ package org.springframework.scheduling.quartz;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -228,7 +227,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
}
else {
// Create empty list for easier checks when registering triggers.
this.jobDetails = new LinkedList<>();
this.jobDetails = new ArrayList<>();
}
// Register Calendars.

View File

@ -21,7 +21,6 @@ import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -403,7 +402,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
Cache.ValueWrapper cacheHit = findCachedItem(contexts.get(CacheableOperation.class));
// Collect puts from any @Cacheable miss, if no cached item is found
List<CachePutRequest> cachePutRequests = new LinkedList<>();
List<CachePutRequest> cachePutRequests = new ArrayList<>();
if (cacheHit == null) {
collectPutRequests(contexts.get(CacheableOperation.class),
CacheOperationExpressionEvaluator.NO_RESULT, cachePutRequests);

View File

@ -18,9 +18,9 @@ package org.springframework.context.annotation;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -93,9 +93,9 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
private String resourcePattern = DEFAULT_RESOURCE_PATTERN;
private final List<TypeFilter> includeFilters = new LinkedList<>();
private final List<TypeFilter> includeFilters = new ArrayList<>();
private final List<TypeFilter> excludeFilters = new LinkedList<>();
private final List<TypeFilter> excludeFilters = new ArrayList<>();
@Nullable
private Environment environment;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -21,9 +21,9 @@ import java.io.InputStream;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -55,7 +55,7 @@ public class ShadowingClassLoader extends DecoratingClassLoader {
private final ClassLoader enclosingClassLoader;
private final List<ClassFileTransformer> classFileTransformers = new LinkedList<>();
private final List<ClassFileTransformer> classFileTransformers = new ArrayList<>(1);
private final Map<String, Class<?>> classCache = new HashMap<>();

View File

@ -18,11 +18,11 @@ package org.springframework.validation;
import java.beans.PropertyEditor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -50,7 +50,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
private MessageCodesResolver messageCodesResolver = new DefaultMessageCodesResolver();
private final List<ObjectError> errors = new LinkedList<>();
private final List<ObjectError> errors = new ArrayList<>();
private final Map<String, Class<?>> fieldTypes = new HashMap<>();
@ -145,7 +145,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
@Override
public List<ObjectError> getGlobalErrors() {
List<ObjectError> result = new LinkedList<>();
List<ObjectError> result = new ArrayList<>();
for (ObjectError objectError : this.errors) {
if (!(objectError instanceof FieldError)) {
result.add(objectError);
@ -167,7 +167,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
@Override
public List<FieldError> getFieldErrors() {
List<FieldError> result = new LinkedList<>();
List<FieldError> result = new ArrayList<>();
for (ObjectError objectError : this.errors) {
if (objectError instanceof FieldError) {
result.add((FieldError) objectError);
@ -189,7 +189,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
@Override
public List<FieldError> getFieldErrors(String field) {
List<FieldError> result = new LinkedList<>();
List<FieldError> result = new ArrayList<>();
String fixedField = fixedField(field);
for (ObjectError objectError : this.errors) {
if (objectError instanceof FieldError && isMatchingFieldError(fixedField, (FieldError) objectError)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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,9 +18,9 @@ package org.springframework.validation;
import java.io.Serializable;
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.NoSuchElementException;
@ -146,7 +146,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
@Override
public List<ObjectError> getAllErrors() {
List<ObjectError> result = new LinkedList<>();
List<ObjectError> result = new ArrayList<>();
result.addAll(getGlobalErrors());
result.addAll(getFieldErrors());
return Collections.unmodifiableList(result);
@ -199,7 +199,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
@Override
public List<FieldError> getFieldErrors(String field) {
List<FieldError> fieldErrors = getFieldErrors();
List<FieldError> result = new LinkedList<>();
List<FieldError> result = new ArrayList<>();
String fixedField = fixedField(field);
for (FieldError error : fieldErrors) {
if (isMatchingFieldError(fixedField, error)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2020 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,9 +17,9 @@
package org.springframework.context.testfixture;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -34,7 +34,7 @@ public class SimpleMapScope implements Scope, Serializable {
private final Map<String, Object> map = new HashMap<>();
private final List<Runnable> callbacks = new LinkedList<>();
private final List<Runnable> callbacks = new ArrayList<>();
public SimpleMapScope() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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,7 +18,7 @@ package org.springframework.core;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import org.springframework.lang.Nullable;
@ -36,7 +36,7 @@ import org.springframework.lang.Nullable;
*/
public class PrioritizedParameterNameDiscoverer implements ParameterNameDiscoverer {
private final List<ParameterNameDiscoverer> parameterNameDiscoverers = new LinkedList<>();
private final List<ParameterNameDiscoverer> parameterNameDiscoverers = new ArrayList<>(2);
/**

View File

@ -17,12 +17,13 @@
package org.springframework.core.convert.support;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -651,7 +652,7 @@ public class GenericConversionService implements ConfigurableConversionService {
*/
private static class ConvertersForPair {
private final LinkedList<GenericConverter> converters = new LinkedList<>();
private final Deque<GenericConverter> converters = new ArrayDeque<>(1);
public void add(GenericConverter converter) {
this.converters.addFirst(converter);

View File

@ -16,9 +16,9 @@
package org.springframework.util;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -655,7 +655,7 @@ public class AntPathMatcher implements PathMatcher {
@Nullable
private final Pattern pattern;
private final List<String> variableNames = new LinkedList<>();
private final List<String> variableNames = new ArrayList<>();
public AntPathStringMatcher(String pattern) {
this(pattern, true);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -20,8 +20,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import org.springframework.lang.Nullable;
@ -50,7 +51,7 @@ public class FastByteArrayOutputStream extends OutputStream {
// The buffers used to store the content bytes
private final LinkedList<byte[]> buffers = new LinkedList<>();
private final Deque<byte[]> buffers = new ArrayDeque<>();
// The size, in bytes, to use when allocating the first byte[]
private final int initialBlockSize;

View File

@ -17,14 +17,14 @@
package org.springframework.util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Simple implementation of {@link MultiValueMap} that wraps a {@link LinkedHashMap},
* storing multiple values in a {@link LinkedList}.
* storing multiple values in an {@link ArrayList}.
*
* <p>This Map implementation is generally not thread-safe. It is primarily designed
* for data structures exposed from request objects, for use in a single thread only.
@ -75,7 +75,7 @@ public class LinkedMultiValueMap<K, V> extends MultiValueMapAdapter<K, V> implem
/**
* Create a deep copy of this Map.
* @return a copy of this Map, including a copy of each value-holding List entry
* (consistently using an independent modifiable {@link LinkedList} for each entry)
* (consistently using an independent modifiable {@link ArrayList} for each entry)
* along the lines of {@code MultiValueMap.addAll} semantics
* @since 4.2
* @see #addAll(MultiValueMap)
@ -83,7 +83,7 @@ public class LinkedMultiValueMap<K, V> extends MultiValueMapAdapter<K, V> implem
*/
public LinkedMultiValueMap<K, V> deepCopy() {
LinkedMultiValueMap<K, V> copy = new LinkedMultiValueMap<>(size());
forEach((key, values) -> copy.put(key, new LinkedList<>(values)));
forEach((key, values) -> copy.put(key, new ArrayList<>(values)));
return copy;
}

View File

@ -17,8 +17,8 @@
package org.springframework.util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -56,13 +56,13 @@ class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializable {
@Override
public void add(K key, @Nullable V value) {
List<V> values = this.targetMap.computeIfAbsent(key, k -> new LinkedList<>());
List<V> values = this.targetMap.computeIfAbsent(key, k -> new ArrayList<>(1));
values.add(value);
}
@Override
public void addAll(K key, List<? extends V> values) {
List<V> currentValues = this.targetMap.computeIfAbsent(key, k -> new LinkedList<>());
List<V> currentValues = this.targetMap.computeIfAbsent(key, k -> new ArrayList<>(1));
currentValues.addAll(values);
}
@ -75,7 +75,7 @@ class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializable {
@Override
public void set(K key, @Nullable V value) {
List<V> values = new LinkedList<>();
List<V> values = new ArrayList<>(1);
values.add(value);
this.targetMap.put(key, values);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,7 @@
package org.springframework.util;
import java.text.NumberFormat;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -55,7 +55,7 @@ public class StopWatch {
private boolean keepTaskList = true;
private final List<TaskInfo> taskList = new LinkedList<>();
private final List<TaskInfo> taskList = new ArrayList<>(1);
/** Start time of the current task. */
private long startTimeNanos;

View File

@ -18,14 +18,15 @@ package org.springframework.util;
import java.io.ByteArrayOutputStream;
import java.nio.charset.Charset;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
@ -693,7 +694,7 @@ public abstract class StringUtils {
}
String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR);
LinkedList<String> pathElements = new LinkedList<>();
Deque<String> pathElements = new ArrayDeque<>();
int tops = 0;
for (int i = pathArray.length - 1; i >= 0; i--) {
@ -712,7 +713,7 @@ public abstract class StringUtils {
}
else {
// Normal path element found.
pathElements.add(0, element);
pathElements.addFirst(element);
}
}
}
@ -723,11 +724,11 @@ public abstract class StringUtils {
}
// Remaining top paths need to be retained.
for (int i = 0; i < tops; i++) {
pathElements.add(0, TOP_PATH);
pathElements.addFirst(TOP_PATH);
}
// If nothing else left, at least explicitly point to current path.
if (pathElements.size() == 1 && pathElements.getLast().isEmpty() && !prefix.endsWith(FOLDER_SEPARATOR)) {
pathElements.add(0, CURRENT_PATH);
pathElements.addFirst(CURRENT_PATH);
}
return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.util.concurrent;
import java.util.LinkedList;
import java.util.ArrayDeque;
import java.util.Queue;
import org.springframework.lang.Nullable;
@ -36,9 +36,9 @@ import org.springframework.util.Assert;
*/
public class ListenableFutureCallbackRegistry<T> {
private final Queue<SuccessCallback<? super T>> successCallbacks = new LinkedList<>();
private final Queue<SuccessCallback<? super T>> successCallbacks = new ArrayDeque<>(1);
private final Queue<FailureCallback> failureCallbacks = new LinkedList<>();
private final Queue<FailureCallback> failureCallbacks = new ArrayDeque<>(1);
private State state = State.NEW;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.expression.spel.support;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.springframework.expression.EvaluationException;
@ -41,7 +41,7 @@ public class StandardTypeLocator implements TypeLocator {
@Nullable
private final ClassLoader classLoader;
private final List<String> knownPackagePrefixes = new LinkedList<>();
private final List<String> knownPackagePrefixes = new ArrayList<>(1);
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -20,8 +20,8 @@ import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -57,7 +57,7 @@ public class CallableStatementCreatorFactory {
*/
public CallableStatementCreatorFactory(String callString) {
this.callString = callString;
this.declaredParameters = new LinkedList<>();
this.declaredParameters = new ArrayList<>();
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -21,10 +21,10 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -66,7 +66,7 @@ public class PreparedStatementCreatorFactory {
*/
public PreparedStatementCreatorFactory(String sql) {
this.sql = sql;
this.declaredParameters = new LinkedList<>();
this.declaredParameters = new ArrayList<>();
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.jdbc.core;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.springframework.lang.Nullable;
@ -186,7 +185,7 @@ public class SqlParameter {
*/
public static List<SqlParameter> sqlTypesToAnonymousParameterList(@Nullable int... types) {
if (types == null) {
return new LinkedList<>();
return new ArrayList<>();
}
List<SqlParameter> result = new ArrayList<>(types.length);
for (int type : types) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,9 +18,9 @@ package org.springframework.jdbc.object;
import java.sql.ResultSet;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -79,7 +79,7 @@ public abstract class RdbmsOperation implements InitializingBean {
@Nullable
private String sql;
private final List<SqlParameter> declaredParameters = new LinkedList<>();
private final List<SqlParameter> declaredParameters = new ArrayList<>();
/**
* Has this operation been compiled? Compilation means at

View File

@ -16,8 +16,8 @@
package org.springframework.jdbc.support;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -47,7 +47,7 @@ public class GeneratedKeyHolder implements KeyHolder {
* Create a new GeneratedKeyHolder with a default list.
*/
public GeneratedKeyHolder() {
this.keyList = new LinkedList<>();
this.keyList = new ArrayList<>(1);
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -20,10 +20,11 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -94,7 +95,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
private volatile boolean active = true;
private final ConcurrentMap<Integer, LinkedList<Session>> cachedSessions = new ConcurrentHashMap<>();
private final ConcurrentMap<Integer, Deque<Session>> cachedSessions = new ConcurrentHashMap<>();
/**
@ -186,7 +187,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
this.active = false;
synchronized (this.cachedSessions) {
for (LinkedList<Session> sessionList : this.cachedSessions.values()) {
for (Deque<Session> sessionList : this.cachedSessions.values()) {
synchronized (sessionList) {
for (Session session : sessionList) {
try {
@ -216,7 +217,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
return null;
}
LinkedList<Session> sessionList = this.cachedSessions.computeIfAbsent(mode, k -> new LinkedList<>());
Deque<Session> sessionList = this.cachedSessions.computeIfAbsent(mode, k -> new ArrayDeque<>());
Session session = null;
synchronized (sessionList) {
if (!sessionList.isEmpty()) {
@ -247,7 +248,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
* @param sessionList the List of cached Sessions that the given Session belongs to
* @return the wrapped Session
*/
protected Session getCachedSessionProxy(Session target, LinkedList<Session> sessionList) {
protected Session getCachedSessionProxy(Session target, Deque<Session> sessionList) {
List<Class<?>> classes = new ArrayList<>(3);
classes.add(SessionProxy.class);
if (target instanceof QueueSession) {
@ -268,7 +269,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
private final Session target;
private final LinkedList<Session> sessionList;
private final Deque<Session> sessionList;
private final Map<DestinationCacheKey, MessageProducer> cachedProducers = new HashMap<>();
@ -276,7 +277,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
private boolean transactionOpen = false;
public CachedSessionInvocationHandler(Session target, LinkedList<Session> sessionList) {
public CachedSessionInvocationHandler(Session target, Deque<Session> sessionList) {
this.target = target;
this.sessionList = sessionList;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,8 +17,9 @@
package org.springframework.jms.connection;
import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import javax.jms.Connection;
@ -58,11 +59,11 @@ public class JmsResourceHolder extends ResourceHolderSupport {
private boolean frozen = false;
private final LinkedList<Connection> connections = new LinkedList<>();
private final Deque<Connection> connections = new ArrayDeque<>();
private final LinkedList<Session> sessions = new LinkedList<>();
private final Deque<Session> sessions = new ArrayDeque<>();
private final Map<Connection, LinkedList<Session>> sessionsPerConnection = new HashMap<>();
private final Map<Connection, Deque<Session>> sessionsPerConnection = new HashMap<>();
/**
@ -155,8 +156,8 @@ public class JmsResourceHolder extends ResourceHolderSupport {
if (!this.sessions.contains(session)) {
this.sessions.add(session);
if (connection != null) {
LinkedList<Session> sessions =
this.sessionsPerConnection.computeIfAbsent(connection, k -> new LinkedList<>());
Deque<Session> sessions =
this.sessionsPerConnection.computeIfAbsent(connection, k -> new ArrayDeque<>());
sessions.add(session);
}
}
@ -223,7 +224,7 @@ public class JmsResourceHolder extends ResourceHolderSupport {
*/
@Nullable
public <S extends Session> S getSession(Class<S> sessionType, @Nullable Connection connection) {
LinkedList<Session> sessions =
Deque<Session> sessions =
(connection != null ? this.sessionsPerConnection.get(connection) : this.sessions);
return CollectionUtils.findValueOfType(sessions, sessionType);
}

View File

@ -16,8 +16,8 @@
package org.springframework.jms.listener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.jms.Connection;
@ -83,7 +83,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
private volatile boolean running;
private final List<Object> pausedTasks = new LinkedList<>();
private final List<Object> pausedTasks = new ArrayList<>();
protected final Object lifecycleMonitor = new Object();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.messaging.handler.invocation;
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;
@ -37,7 +37,7 @@ import org.springframework.messaging.Message;
*/
public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentResolver {
private final List<HandlerMethodArgumentResolver> argumentResolvers = new LinkedList<>();
private final List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
private final Map<MethodParameter, HandlerMethodArgumentResolver> argumentResolverCache =
new ConcurrentHashMap<>(256);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.messaging.handler.invocation.reactive;
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;
@ -42,7 +42,7 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
protected final Log logger = LogFactory.getLog(getClass());
private final List<HandlerMethodArgumentResolver> argumentResolvers = new LinkedList<>();
private final List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
private final Map<MethodParameter, HandlerMethodArgumentResolver> argumentResolverCache =
new ConcurrentHashMap<>(256);
@ -113,9 +113,8 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
public Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) {
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
if (resolver == null) {
throw new IllegalArgumentException(
"Unsupported parameter type [" + parameter.getParameterType().getName() + "]." +
" supportsParameter should be called first.");
throw new IllegalArgumentException("Unsupported parameter type [" +
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
}
return resolver.resolveArgument(parameter, message);
}

View File

@ -17,9 +17,9 @@
package org.springframework.messaging.simp.stomp;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -228,15 +228,14 @@ public class StompEncoder {
void add(byte b);
byte[] toByteArray();
}
@SuppressWarnings("serial")
private static class DefaultResult extends LinkedList<Object> implements Result {
private static class DefaultResult extends ArrayList<Object> implements Result {
private int size;
public void add(byte[] bytes) {
this.size += bytes.length;
super.add(bytes);

View File

@ -17,11 +17,11 @@
package org.springframework.messaging.simp.stomp;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -446,13 +446,13 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
*/
@Override
public void add(String headerName, @Nullable String headerValue) {
List<String> headerValues = this.headers.computeIfAbsent(headerName, k -> new LinkedList<>());
List<String> headerValues = this.headers.computeIfAbsent(headerName, k -> new ArrayList<>(1));
headerValues.add(headerValue);
}
@Override
public void addAll(String headerName, List<? extends String> headerValues) {
List<String> currentValues = this.headers.computeIfAbsent(headerName, k -> new LinkedList<>());
List<String> currentValues = this.headers.computeIfAbsent(headerName, k -> new ArrayList<>(1));
currentValues.addAll(headerValues);
}
@ -471,7 +471,7 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
*/
@Override
public void set(String headerName, @Nullable String headerValue) {
List<String> headerValues = new LinkedList<>();
List<String> headerValues = new ArrayList<>(1);
headerValues.add(headerValue);
this.headers.put(headerName, headerValues);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.messaging.support;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -166,7 +166,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor {
map = new LinkedMultiValueMap<>(3);
setHeader(NATIVE_HEADERS, map);
}
List<String> values = new LinkedList<>();
List<String> values = new ArrayList<>(1);
values.add(value);
if (!ObjectUtils.nullSafeEquals(values, getHeader(name))) {
setModified(true);
@ -187,7 +187,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor {
nativeHeaders = new LinkedMultiValueMap<>(3);
setHeader(NATIVE_HEADERS, nativeHeaders);
}
List<String> values = nativeHeaders.computeIfAbsent(name, k -> new LinkedList<>());
List<String> values = nativeHeaders.computeIfAbsent(name, k -> new ArrayList<>(1));
values.add(value);
setModified(true);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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,10 +18,10 @@ package org.springframework.orm.jpa.persistenceunit;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -498,7 +498,7 @@ public class DefaultPersistenceUnitManager
* as defined in the JPA specification.
*/
private List<SpringPersistenceUnitInfo> readPersistenceUnitInfos() {
List<SpringPersistenceUnitInfo> infos = new LinkedList<>();
List<SpringPersistenceUnitInfo> infos = new ArrayList<>(1);
String defaultName = this.defaultPersistenceUnitName;
boolean buildDefaultUnit = (this.packagesToScan != null || this.mappingResources != null);
boolean foundDefaultUnit = false;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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,7 @@
package org.springframework.orm.jpa.persistenceunit;
import java.net.URL;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -61,16 +61,16 @@ public class MutablePersistenceUnitInfo implements SmartPersistenceUnitInfo {
@Nullable
private DataSource jtaDataSource;
private final List<String> mappingFileNames = new LinkedList<>();
private final List<String> mappingFileNames = new ArrayList<>();
private List<URL> jarFileUrls = new LinkedList<>();
private final List<URL> jarFileUrls = new ArrayList<>();
@Nullable
private URL persistenceUnitRootUrl;
private final List<String> managedClassNames = new LinkedList<>();
private final List<String> managedClassNames = new ArrayList<>();
private final List<String> managedPackages = new LinkedList<>();
private final List<String> managedPackages = new ArrayList<>();
private boolean excludeUnlistedClasses = false;

View File

@ -19,7 +19,7 @@ package org.springframework.orm.jpa.persistenceunit;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.SharedCacheMode;
@ -123,7 +123,7 @@ final class PersistenceUnitReader {
*/
public SpringPersistenceUnitInfo[] readPersistenceUnitInfos(String[] persistenceXmlLocations) {
ErrorHandler handler = new SimpleSaxErrorHandler(logger);
List<SpringPersistenceUnitInfo> infos = new LinkedList<>();
List<SpringPersistenceUnitInfo> infos = new ArrayList<>(1);
String resourceLocation = null;
try {
for (String location : persistenceXmlLocations) {

View File

@ -24,7 +24,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -403,7 +402,7 @@ public class PersistenceAnnotationBeanPostProcessor
Class<?> targetClass = clazz;
do {
final LinkedList<InjectionMetadata.InjectedElement> currElements = new LinkedList<>();
final List<InjectionMetadata.InjectedElement> currElements = new ArrayList<>();
ReflectionUtils.doWithLocalFields(targetClass, field -> {
if (field.isAnnotationPresent(PersistenceContext.class) ||

View File

@ -18,11 +18,11 @@ package org.springframework.test.web.client;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -48,9 +48,9 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractRequestExpectationManager implements RequestExpectationManager {
private final List<RequestExpectation> expectations = new LinkedList<>();
private final List<RequestExpectation> expectations = new ArrayList<>();
private final List<ClientHttpRequest> requests = new LinkedList<>();
private final List<ClientHttpRequest> requests = new ArrayList<>();
private final Map<ClientHttpRequest, Throwable> requestFailures = new LinkedHashMap<>();
@ -81,7 +81,7 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
@SuppressWarnings("deprecation")
@Override
public ClientHttpResponse validateRequest(ClientHttpRequest request) throws IOException {
RequestExpectation expectation = null;
RequestExpectation expectation;
synchronized (this.requests) {
if (this.requests.isEmpty()) {
afterExpectationsDeclared();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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,7 @@
package org.springframework.test.web.client;
import java.io.IOException;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import org.springframework.http.client.ClientHttpRequest;
@ -36,7 +36,7 @@ public class DefaultRequestExpectation implements RequestExpectation {
private final RequestCount requestCount;
private final List<RequestMatcher> requestMatchers = new LinkedList<>();
private final List<RequestMatcher> requestMatchers = new ArrayList<>(1);
@Nullable
private ResponseCreator responseCreator;

View File

@ -16,7 +16,7 @@
package org.springframework.transaction.config;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.Element;
@ -122,14 +122,14 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
attribute.setReadOnly(Boolean.parseBoolean(methodEle.getAttribute(READ_ONLY_ATTRIBUTE)));
}
List<RollbackRuleAttribute> rollbackRules = new LinkedList<>();
List<RollbackRuleAttribute> rollbackRules = new ArrayList<>(1);
if (methodEle.hasAttribute(ROLLBACK_FOR_ATTRIBUTE)) {
String rollbackForValue = methodEle.getAttribute(ROLLBACK_FOR_ATTRIBUTE);
addRollbackRuleAttributesTo(rollbackRules,rollbackForValue);
addRollbackRuleAttributesTo(rollbackRules, rollbackForValue);
}
if (methodEle.hasAttribute(NO_ROLLBACK_FOR_ATTRIBUTE)) {
String noRollbackForValue = methodEle.getAttribute(NO_ROLLBACK_FOR_ATTRIBUTE);
addNoRollbackRuleAttributesTo(rollbackRules,noRollbackForValue);
addNoRollbackRuleAttributesTo(rollbackRules, noRollbackForValue);
}
attribute.setRollbackRules(rollbackRules);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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,7 +18,6 @@ package org.springframework.transaction.interceptor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.logging.Log;
@ -116,7 +115,7 @@ public class RuleBasedTransactionAttribute extends DefaultTransactionAttribute i
*/
public List<RollbackRuleAttribute> getRollbackRules() {
if (this.rollbackRules == null) {
this.rollbackRules = new LinkedList<>();
this.rollbackRules = new ArrayList<>();
}
return this.rollbackRules;
}

View File

@ -23,8 +23,8 @@ import java.nio.channels.WritableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -479,7 +479,7 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
}
private void switchToFile(DataBuffer current, long byteCount) {
List<DataBuffer> content = new LinkedList<>(this.content);
List<DataBuffer> content = new ArrayList<>(this.content);
content.add(current);
this.releaseOnDispose = false;

View File

@ -21,7 +21,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -557,7 +556,7 @@ public class Jackson2ObjectMapperBuilder {
* @see com.fasterxml.jackson.databind.Module
*/
public Jackson2ObjectMapperBuilder modules(List<Module> modules) {
this.modules = new LinkedList<>(modules);
this.modules = new ArrayList<>(modules);
this.findModulesViaServiceLoader = false;
this.findWellKnownModules = false;
return this;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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,9 @@
package org.springframework.web;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -117,7 +117,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
if (this.supportedMethods == null) {
return null;
}
List<HttpMethod> supportedMethods = new LinkedList<>();
List<HttpMethod> supportedMethods = new ArrayList<>(this.supportedMethods.length);
for (String value : this.supportedMethods) {
HttpMethod resolved = HttpMethod.resolve(value);
if (resolved != null) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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,8 @@
package org.springframework.web;
import java.lang.reflect.Modifier;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
@ -142,9 +143,10 @@ public class SpringServletContainerInitializer implements ServletContainerInitia
public void onStartup(@Nullable Set<Class<?>> webAppInitializerClasses, ServletContext servletContext)
throws ServletException {
List<WebApplicationInitializer> initializers = new LinkedList<>();
List<WebApplicationInitializer> initializers = Collections.emptyList();
if (webAppInitializerClasses != null) {
initializers = new ArrayList<>(webAppInitializerClasses.size());
for (Class<?> waiClass : webAppInitializerClasses) {
// Be defensive: Some servlet containers provide us with invalid classes,
// no matter what @HandlesTypes says...

View File

@ -21,7 +21,6 @@ import java.lang.reflect.Type;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -949,7 +948,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
HttpHeaders httpHeaders = httpRequest.getHeaders();
HttpHeaders requestHeaders = this.requestEntity.getHeaders();
if (!requestHeaders.isEmpty()) {
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new LinkedList<>(values)));
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new ArrayList<>(values)));
}
if (httpHeaders.getContentLength() < 0) {
httpHeaders.setContentLength(0L);
@ -968,7 +967,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
(GenericHttpMessageConverter<Object>) messageConverter;
if (genericConverter.canWrite(requestBodyType, requestBodyClass, requestContentType)) {
if (!requestHeaders.isEmpty()) {
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new LinkedList<>(values)));
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new ArrayList<>(values)));
}
logBody(requestBody, requestContentType, genericConverter);
genericConverter.write(requestBody, requestBodyType, requestContentType, httpRequest);
@ -977,7 +976,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
else if (messageConverter.canWrite(requestBodyClass, requestContentType)) {
if (!requestHeaders.isEmpty()) {
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new LinkedList<>(values)));
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new ArrayList<>(values)));
}
logBody(requestBody, requestContentType, messageConverter);
((HttpMessageConverter<Object>) messageConverter).write(

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.web.method.support;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -34,11 +35,12 @@ import org.springframework.web.util.UriComponentsBuilder;
* use for formatting method argument values to Strings.
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 4.0
*/
public class CompositeUriComponentsContributor implements UriComponentsContributor {
private final List<Object> contributors = new LinkedList<>();
private final List<Object> contributors;
private final ConversionService conversionService;
@ -53,7 +55,7 @@ public class CompositeUriComponentsContributor implements UriComponentsContribut
* or {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
*/
public CompositeUriComponentsContributor(UriComponentsContributor... contributors) {
Collections.addAll(this.contributors, contributors);
this.contributors = Arrays.asList((Object[]) contributors);
this.conversionService = new DefaultFormattingConversionService();
}
@ -85,9 +87,7 @@ public class CompositeUriComponentsContributor implements UriComponentsContribut
* need to be formatted as Strings before being added to the URI
*/
public CompositeUriComponentsContributor(@Nullable Collection<?> contributors, @Nullable ConversionService cs) {
if (contributors != null) {
this.contributors.addAll(contributors);
}
this.contributors = (contributors != null ? new ArrayList<>(contributors) : Collections.emptyList());
this.conversionService = (cs != null ? cs : new DefaultFormattingConversionService());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.web.method.support;
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;
@ -38,7 +38,7 @@ import org.springframework.web.context.request.NativeWebRequest;
*/
public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentResolver {
private final List<HandlerMethodArgumentResolver> argumentResolvers = new LinkedList<>();
private final List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
private final Map<MethodParameter, HandlerMethodArgumentResolver> argumentResolverCache =
new ConcurrentHashMap<>(256);

View File

@ -16,7 +16,7 @@
package org.springframework.web.multipart.support;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
@ -65,7 +65,7 @@ public abstract class StandardServletPartUtils {
*/
public static List<Part> getParts(HttpServletRequest request, String name) throws MultipartException {
try {
List<Part> parts = new LinkedList<>();
List<Part> parts = new ArrayList<>(1);
for (Part part : request.getParts()) {
if (part.getName().equals(name)) {
parts.add(part);

View File

@ -20,10 +20,11 @@ import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
@ -908,7 +909,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
private static class CompositePathComponentBuilder implements PathComponentBuilder {
private final LinkedList<PathComponentBuilder> builders = new LinkedList<>();
private final Deque<PathComponentBuilder> builders = new ArrayDeque<>();
public void addPathSegments(String... pathSegments) {
if (!ObjectUtils.isEmpty(pathSegments)) {
@ -1024,7 +1025,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
private static class PathSegmentComponentBuilder implements PathComponentBuilder {
private final List<String> pathSegments = new LinkedList<>();
private final List<String> pathSegments = new ArrayList<>();
public void append(String... pathSegments) {
for (String pathSegment : pathSegments) {

View File

@ -16,7 +16,7 @@
package org.springframework.web.util.pattern;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -40,7 +40,7 @@ class RegexPathElement extends PathElement {
private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
private char[] regex;
private final char[] regex;
private final boolean caseSensitive;
@ -48,7 +48,7 @@ class RegexPathElement extends PathElement {
private int wildcardCount;
private final List<String> variableNames = new LinkedList<>();
private final List<String> variableNames = new ArrayList<>();
RegexPathElement(int pos, char[] regex, boolean caseSensitive, char[] completePattern, char separator) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.web.reactive.result.method;
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;
@ -43,7 +43,7 @@ class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentRes
protected final Log logger = LogFactory.getLog(getClass());
private final List<HandlerMethodArgumentResolver> argumentResolvers = new LinkedList<>();
private final List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
private final Map<MethodParameter, HandlerMethodArgumentResolver> argumentResolverCache =
new ConcurrentHashMap<>(256);
@ -116,9 +116,8 @@ class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentRes
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
if (resolver == null) {
throw new IllegalArgumentException(
"Unsupported parameter type [" + parameter.getParameterType().getName() + "]." +
" supportsParameter should be called first.");
throw new IllegalArgumentException("Unsupported parameter type [" +
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
}
return resolver.resolveArgument(parameter, bindingContext, exchange);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -86,7 +86,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
* Configure the argument resolvers to use to use for resolving method
* argument values against a {@code ServerWebExchange}.
*/
public void setArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
public void setArgumentResolvers(List<? extends HandlerMethodArgumentResolver> resolvers) {
this.resolvers.addResolvers(resolvers);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.web.reactive.result.method;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -62,7 +61,7 @@ public class SyncInvocableHandlerMethod extends HandlerMethod {
* argument values against a {@code ServerWebExchange}.
*/
public void setArgumentResolvers(List<SyncHandlerMethodArgumentResolver> resolvers) {
this.delegate.setArgumentResolvers(new ArrayList<>(resolvers));
this.delegate.setArgumentResolvers(resolvers);
}
/**

View File

@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -897,7 +896,7 @@ public class DispatcherServlet extends FrameworkServlet {
return strategies;
}
else {
return new LinkedList<>();
return Collections.emptyList();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.web.servlet.support;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@ -127,7 +127,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
* Return a list of expired FlashMap instances contained in the given list.
*/
private List<FlashMap> getExpiredFlashMaps(List<FlashMap> allMaps) {
List<FlashMap> result = new LinkedList<>();
List<FlashMap> result = new ArrayList<>();
for (FlashMap map : allMaps) {
if (map.isExpired()) {
result.add(map);
@ -142,7 +142,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
*/
@Nullable
private FlashMap getMatchingFlashMap(List<FlashMap> allMaps, HttpServletRequest request) {
List<FlashMap> result = new LinkedList<>();
List<FlashMap> result = new ArrayList<>();
for (FlashMap flashMap : allMaps) {
if (isFlashMapForRequest(flashMap, request)) {
result.add(flashMap);
@ -213,7 +213,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
}
else {
List<FlashMap> allFlashMaps = retrieveFlashMaps(request);
allFlashMaps = (allFlashMaps != null ? allFlashMaps : new LinkedList<>());
allFlashMaps = (allFlashMaps != null ? allFlashMaps : new ArrayList<>(1));
allFlashMaps.add(flashMap);
updateFlashMaps(allFlashMaps, request, response);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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,9 +17,9 @@
package org.springframework.web.servlet.tags;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.jsp.JspException;
@ -255,7 +255,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
@Override
protected final int doStartTagInternal() throws JspException, IOException {
this.nestedArguments = new LinkedList<>();
this.nestedArguments = new ArrayList<>();
return EVAL_BODY_INCLUDE;
}

View File

@ -18,9 +18,9 @@ package org.springframework.web.servlet.tags;
import java.io.IOException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -229,7 +229,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
@Override
public int doStartTagInternal() throws JspException {
this.params = new LinkedList<>();
this.params = new ArrayList<>();
this.templateParams = new HashSet<>();
return EVAL_BODY_INCLUDE;
}

View File

@ -16,8 +16,8 @@
package org.springframework.web.servlet.view;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -230,10 +230,9 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
}
// Build list of ResourceBundle references for Locale.
List<ResourceBundle> bundles = new LinkedList<>();
List<ResourceBundle> bundles = new ArrayList<>(this.basenames.length);
for (String basename : this.basenames) {
ResourceBundle bundle = getBundle(basename, locale);
bundles.add(bundle);
bundles.add(getBundle(basename, locale));
}
// Try to find cached factory for ResourceBundle list:

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.web.servlet.view.tiles3;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import javax.el.ArrayELResolver;
@ -311,7 +311,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
if (definitions != null) {
List<ApplicationResource> result = new LinkedList<>();
List<ApplicationResource> result = new ArrayList<>();
for (String definition : definitions) {
Collection<ApplicationResource> resources = applicationContext.getResources(definition);
if (resources != null) {