From dbbdd044cdd5439e4066b71af34324670a274514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B6=E8=8B=97?= Date: Wed, 4 Mar 2020 11:46:50 +0800 Subject: [PATCH 1/2] Use Collections.addAll instead of Collection.addAll See gh-24636 --- .../main/java/org/springframework/util/CollectionUtils.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java index a574fff2674..0bb29244698 100644 --- a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java @@ -129,9 +129,7 @@ public abstract class CollectionUtils { @SuppressWarnings("unchecked") public static void mergeArrayIntoCollection(@Nullable Object array, Collection collection) { Object[] arr = ObjectUtils.toObjectArray(array); - for (Object elem : arr) { - collection.add((E) elem); - } + Collections.addAll(collection, (E[])arr); } /** From ca6911a532925e8f2a4d8c0901e5536dd60d1841 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 21 Dec 2021 09:49:08 +0100 Subject: [PATCH 2/2] Update copyright year of changed file See gh-24636 --- .../src/main/java/org/springframework/util/CollectionUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java index 0bb29244698..1eadaa5680f 100644 --- a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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.