Skip to content

Commit

Permalink
spring-projectsgh-25650 Replace remaining usage of LinkedList with Ar…
Browse files Browse the repository at this point in the history
…rayList in tests
  • Loading branch information
stsypanov authored and jhoeller committed Aug 31, 2020
1 parent 79cf6b4 commit 1f3e52d
Show file tree
Hide file tree
Showing 28 changed files with 126 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.lang.reflect.UndeclaredThrowableException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.aspectj.lang.JoinPoint;
Expand Down Expand Up @@ -136,7 +135,7 @@ void multiplePerTargetAspects() throws SecurityException, NoSuchMethodException
int realAge = 65;
target.setAge(realAge);

List<Advisor> advisors = new LinkedList<>();
List<Advisor> advisors = new ArrayList<>();
PerTargetAspect aspect1 = new PerTargetAspect();
aspect1.count = 100;
aspect1.setOrder(10);
Expand Down Expand Up @@ -164,7 +163,7 @@ void multiplePerTargetAspectsWithOrderAnnotation() throws SecurityException, NoS
int realAge = 65;
target.setAge(realAge);

List<Advisor> advisors = new LinkedList<>();
List<Advisor> advisors = new ArrayList<>();
PerTargetAspectWithOrderAnnotation10 aspect1 = new PerTargetAspectWithOrderAnnotation10();
aspect1.count = 100;
advisors.addAll(
Expand Down Expand Up @@ -392,7 +391,7 @@ void introductionOnTargetImplementingInterface() {

@Test
void introductionOnTargetExcludedByTypePattern() {
LinkedList<Object> target = new LinkedList<>();
ArrayList<Object> target = new ArrayList<>();
List<?> proxy = (List<?>) createProxy(target,
AopUtils.findAdvisorsThatCanApply(
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(), "someBean")),
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,7 +25,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -1072,7 +1071,7 @@ public void setPrimitiveArrayPropertyWithAutoGrow() throws Exception {
public void setGenericArrayProperty() {
SkipReaderStub target = new SkipReaderStub();
AbstractPropertyAccessor accessor = createAccessor(target);
List<String> values = new LinkedList<>();
List<String> values = new ArrayList<>();
values.add("1");
values.add("2");
values.add("3");
Expand Down Expand Up @@ -1113,7 +1112,7 @@ public void setCollectionProperty() {
SortedSet<String> sortedSet = new TreeSet<>();
sortedSet.add("sortedSet1");
accessor.setPropertyValue("sortedSet", sortedSet);
List<String> list = new LinkedList<>();
List<String> list = new ArrayList<>();
list.add("list1");
accessor.setPropertyValue("list", list);
assertThat(target.getCollection()).isSameAs(coll);
Expand All @@ -1130,7 +1129,7 @@ public void setCollectionPropertyNonMatchingType() {
Collection<String> coll = new ArrayList<>();
coll.add("coll1");
accessor.setPropertyValue("collection", coll);
List<String> set = new LinkedList<>();
List<String> set = new ArrayList<>();
set.add("set1");
accessor.setPropertyValue("set", set);
List<String> sortedSet = new ArrayList<>();
Expand All @@ -1157,7 +1156,7 @@ public void setCollectionPropertyWithArrayValue() {
Collection<String> coll = new HashSet<>();
coll.add("coll1");
accessor.setPropertyValue("collection", coll.toArray());
List<String> set = new LinkedList<>();
List<String> set = new ArrayList<>();
set.add("set1");
accessor.setPropertyValue("set", set.toArray());
List<String> sortedSet = new ArrayList<>();
Expand All @@ -1184,7 +1183,7 @@ public void setCollectionPropertyWithIntArrayValue() {
Collection<Integer> coll = new HashSet<>();
coll.add(0);
accessor.setPropertyValue("collection", new int[] {0});
List<Integer> set = new LinkedList<>();
List<Integer> set = new ArrayList<>();
set.add(1);
accessor.setPropertyValue("set", new int[] {1});
List<Integer> sortedSet = new ArrayList<>();
Expand All @@ -1211,7 +1210,7 @@ public void setCollectionPropertyWithIntegerValue() {
Collection<Integer> coll = new HashSet<>();
coll.add(0);
accessor.setPropertyValue("collection", 0);
List<Integer> set = new LinkedList<>();
List<Integer> set = new ArrayList<>();
set.add(1);
accessor.setPropertyValue("set", 1);
List<Integer> sortedSet = new ArrayList<>();
Expand All @@ -1235,7 +1234,7 @@ public void setCollectionPropertyWithIntegerValue() {
public void setCollectionPropertyWithStringValue() {
IndexedTestBean target = new IndexedTestBean();
AbstractPropertyAccessor accessor = createAccessor(target);
List<String> set = new LinkedList<>();
List<String> set = new ArrayList<>();
set.add("set1");
accessor.setPropertyValue("set", "set1");
List<String> sortedSet = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -197,8 +196,8 @@ public void testGenericMapFromProperties() {
@Test
public void testGenericListOfLists() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new LinkedList<>();
list.add(new LinkedList<>());
List<List<Integer>> list = new ArrayList<>();
list.add(new ArrayList<>());
gb.setListOfLists(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", 5);
Expand All @@ -209,8 +208,8 @@ public void testGenericListOfLists() throws MalformedURLException {
@Test
public void testGenericListOfListsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new LinkedList<>();
list.add(new LinkedList<>());
List<List<Integer>> list = new ArrayList<>();
list.add(new ArrayList<>());
gb.setListOfLists(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", "5");
Expand Down Expand Up @@ -246,7 +245,7 @@ public void testGenericListOfArraysWithElementConversion() throws MalformedURLEx
@Test
public void testGenericListOfMaps() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new LinkedList<>();
List<Map<Integer, Long>> list = new ArrayList<>();
list.add(new HashMap<>());
gb.setListOfMaps(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
Expand All @@ -258,7 +257,7 @@ public void testGenericListOfMaps() throws MalformedURLException {
@Test
public void testGenericListOfMapsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new LinkedList<>();
List<Map<Integer, Long>> list = new ArrayList<>();
list.add(new HashMap<>());
gb.setListOfMaps(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
Expand Down Expand Up @@ -295,7 +294,7 @@ public void testGenericMapOfMapsWithElementConversion() throws MalformedURLExcep
public void testGenericMapOfLists() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new LinkedList<>());
map.put(1, new ArrayList<>());
gb.setMapOfLists(map);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfLists[1][0]", 5);
Expand All @@ -307,7 +306,7 @@ public void testGenericMapOfLists() throws MalformedURLException {
public void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new LinkedList<>());
map.put(1, new ArrayList<>());
gb.setMapOfLists(map);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfLists[1][0]", "5");
Expand Down Expand Up @@ -347,7 +346,7 @@ public void testGenericTypeNestingMapOfListOfInteger() throws Exception {

@Test
public void testGenericTypeNestingListOfMapOfInteger() throws Exception {
List<Map<String, String>> list = new LinkedList<>();
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> map = new HashMap<>();
map.put("testKey", "5");
list.add(map);
Expand Down Expand Up @@ -381,9 +380,9 @@ public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
@Test
public void testComplexGenericMap() {
Map<List<String>, List<String>> inputMap = new HashMap<>();
List<String> inputKey = new LinkedList<>();
List<String> inputKey = new ArrayList<>();
inputKey.add("1");
List<String> inputValue = new LinkedList<>();
List<String> inputValue = new ArrayList<>();
inputValue.add("10");
inputMap.put(inputKey, inputValue);

Expand Down Expand Up @@ -414,7 +413,7 @@ public void testComplexGenericMapWithCollectionConversion() {

@Test
public void testComplexGenericIndexedMapEntry() {
List<String> inputValue = new LinkedList<>();
List<String> inputValue = new ArrayList<>();
inputValue.add("10");

ComplexMapHolder holder = new ComplexMapHolder();
Expand All @@ -440,7 +439,7 @@ public void testComplexGenericIndexedMapEntryWithCollectionConversion() {

@Test
public void testComplexDerivedIndexedMapEntry() {
List<String> inputValue = new LinkedList<>();
List<String> inputValue = new ArrayList<>();
inputValue.add("10");

ComplexMapHolder holder = new ComplexMapHolder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
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.Properties;
Expand Down Expand Up @@ -2709,7 +2709,7 @@ public static class SelfInjectionBean {


@SuppressWarnings("serial")
public static class SelfInjectionCollectionBean extends LinkedList<SelfInjectionCollectionBean> {
public static class SelfInjectionCollectionBean extends ArrayList<SelfInjectionCollectionBean> {

@Autowired
public SelfInjectionCollectionBean reference;
Expand Down Expand Up @@ -2833,15 +2833,15 @@ public TestBean consumeUniqueTestBean() {
}

public List<TestBean> iterateTestBeans() {
List<TestBean> resolved = new LinkedList<>();
List<TestBean> resolved = new ArrayList<>();
for (TestBean tb : this.testBeanProvider) {
resolved.add(tb);
}
return resolved;
}

public List<TestBean> forEachTestBeans() {
List<TestBean> resolved = new LinkedList<>();
List<TestBean> resolved = new ArrayList<>();
this.testBeanProvider.forEach(resolved::add);
return resolved;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,7 +16,7 @@

package org.springframework.beans.factory.config;

import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -47,7 +47,7 @@ public void setup() {
beanFactory = new DefaultListableBeanFactory();
Scope scope = new NoOpScope() {
private int index;
private List<TestBean> objects = new LinkedList<>(); {
private List<TestBean> objects = new ArrayList<>(); {
objects.add(new TestBean());
objects.add(new TestBean());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -960,7 +959,7 @@ public void testGenericMatchingWithUnresolvedOrderedStream() {


@SuppressWarnings("serial")
public static class NamedUrlList extends LinkedList<URL> {
public static class NamedUrlList extends ArrayList<URL> {
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -28,7 +28,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -406,7 +405,7 @@ public static class Parent {
private Set<Child> childSet = new LinkedHashSet<>();

@Valid
private List<Child> childList = new LinkedList<>();
private List<Child> childList = new ArrayList<>();

public Integer getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -20,10 +20,10 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -295,7 +295,7 @@ public static class ValidPerson {
private ValidAddress address = new ValidAddress();

@Valid
private List<ValidAddress> addressList = new LinkedList<>();
private List<ValidAddress> addressList = new ArrayList<>();

@Valid
private Set<ValidAddress> addressSet = new LinkedHashSet<>();
Expand Down Expand Up @@ -457,7 +457,7 @@ public boolean isValid(InnerBean bean, ConstraintValidatorContext context) {
public static class ListContainer {

@NotXList
private List<String> list = new LinkedList<>();
private List<String> list = new ArrayList<>();

public void addString(String value) {
list.add(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import java.lang.reflect.UndeclaredThrowableException;
import java.rmi.MarshalException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -1128,7 +1128,7 @@ public Object invoke(MethodInvocation mi) throws Throwable {
};

class NameSaver implements MethodInterceptor {
private List<Object> names = new LinkedList<>();
private List<Object> names = new ArrayList<>();

@Override
public Object invoke(MethodInvocation mi) throws Throwable {
Expand Down
Loading

0 comments on commit 1f3e52d

Please sign in to comment.