From 481283d2f1afa6926324f2fb9c736138ef05900d Mon Sep 17 00:00:00 2001 From: Patrick Strawderman Date: Thu, 15 Feb 2024 09:45:19 -0800 Subject: [PATCH 1/2] Use Spliterator of underlying collection Delegate to the spliterator method of the underlying collection in MutablePropertyValues and MutablePropertySources. In both cases, those collection types have specialized Spliterator implementations. Delegating to these Spliterators also means the characteristics of the Spliterator are properly set. See gh-32281 --- .../java/org/springframework/beans/MutablePropertyValues.java | 3 +-- .../org/springframework/core/env/MutablePropertySources.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java index 62543e9a8cf..24c85654de6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.Spliterator; -import java.util.Spliterators; import java.util.stream.Stream; import org.springframework.lang.Nullable; @@ -255,7 +254,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { @Override public Spliterator spliterator() { - return Spliterators.spliterator(this.propertyValueList, 0); + return this.propertyValueList.spliterator(); } @Override diff --git a/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java b/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java index 0edb4fe0c37..f9c113772fc 100644 --- a/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java +++ b/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java @@ -19,7 +19,6 @@ package org.springframework.core.env; import java.util.Iterator; import java.util.List; import java.util.Spliterator; -import java.util.Spliterators; import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Stream; @@ -69,7 +68,7 @@ public class MutablePropertySources implements PropertySources { @Override public Spliterator> spliterator() { - return Spliterators.spliterator(this.propertySourceList, 0); + return this.propertySourceList.spliterator(); } @Override From 6b8105aef27496e28ef80470c02d6c0c5019ff74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Fri, 16 Feb 2024 08:33:17 +0100 Subject: [PATCH 2/2] Update copyright year of changed files See gh-32281 --- .../java/org/springframework/beans/MutablePropertyValues.java | 2 +- .../org/springframework/core/env/MutablePropertySources.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java index 24c85654de6..f52780e0ec9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. diff --git a/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java b/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java index f9c113772fc..bedb7918c15 100644 --- a/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java +++ b/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 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.