Browse Source

Replace Collectors.toList with Stream.toList

Closes gh-29203
pull/28984/head
Adam Ostrožlík 2 years ago committed by Brian Clozel
parent
commit
0ccb64fe10
  1. 2
      spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
  2. 5
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
  3. 6
      spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java
  4. 3
      spring-context-indexer/src/test/java/org/springframework/context/index/processor/Metadata.java
  5. 3
      spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java
  6. 3
      spring-context/src/main/java/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.java
  7. 3
      spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBeanMethodTests.java
  8. 3
      spring-context/src/testFixtures/java/org/springframework/context/testfixture/index/CandidateComponentsTestClassLoader.java
  9. 5
      spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java
  10. 2
      spring-core/src/jmh/java/org/springframework/core/convert/support/GenericConversionServiceBenchmark.java
  11. 3
      spring-core/src/main/java/org/springframework/core/KotlinReflectionParameterNameDiscoverer.java
  12. 3
      spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java
  13. 5
      spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java
  14. 3
      spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java
  15. 3
      spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBufferFactory.java
  16. 3
      spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java
  17. 6
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java
  18. 3
      spring-web/src/main/java/org/springframework/http/client/reactive/AbstractClientHttpRequest.java
  19. 3
      spring-web/src/main/java/org/springframework/http/client/reactive/JettyHeadersAdapter.java
  20. 3
      spring-web/src/main/java/org/springframework/http/client/reactive/Netty5HeadersAdapter.java
  21. 3
      spring-web/src/main/java/org/springframework/http/client/reactive/NettyHeadersAdapter.java
  22. 3
      spring-web/src/main/java/org/springframework/http/codec/protobuf/ProtobufEncoder.java
  23. 3
      spring-web/src/main/java/org/springframework/http/server/reactive/JettyHeadersAdapter.java
  24. 3
      spring-web/src/main/java/org/springframework/http/server/reactive/Netty5HeadersAdapter.java
  25. 3
      spring-web/src/main/java/org/springframework/http/server/reactive/NettyHeadersAdapter.java
  26. 3
      spring-web/src/main/java/org/springframework/http/server/reactive/TomcatHeadersAdapter.java
  27. 3
      spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java
  28. 3
      spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
  29. 7
      spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java
  30. 7
      spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java
  31. 3
      spring-web/src/main/java/org/springframework/web/server/session/CookieWebSessionIdResolver.java
  32. 3
      spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java
  33. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilder.java
  34. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurerComposite.java
  35. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java
  36. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java
  37. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
  38. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java
  39. 2
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java
  40. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncInvocableHandlerMethod.java
  41. 7
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java
  42. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelInitializer.java
  43. 3
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java
  44. 3
      spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java
  45. 3
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java
  46. 3
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistry.java
  47. 3
      spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultEntityResponseBuilder.java
  48. 3
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java
  49. 3
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java

2
spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java

@ -2020,7 +2020,7 @@ class DefaultListableBeanFactoryTests { @@ -2020,7 +2020,7 @@ class DefaultListableBeanFactoryTests {
lbf.setParentBeanFactory(parentBf);
lbf.registerBeanDefinition("low", new RootBeanDefinition(LowPriorityTestBean.class));
List<Class<?>> orderedTypes = lbf.getBeanProvider(TestBean.class).orderedStream()
.map(Object::getClass).collect(Collectors.toList());
.map(Object::getClass).toList();
assertThat(orderedTypes).containsExactly(
HighPriorityTestBean.class, LowPriorityTestBean.class, TestBean.class);
}

5
spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java

@ -37,7 +37,6 @@ import java.util.Set; @@ -37,7 +37,6 @@ import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -3016,11 +3015,11 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -3016,11 +3015,11 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
public List<TestBean> streamTestBeans() {
return this.testBeanProvider.stream().collect(Collectors.toList());
return this.testBeanProvider.stream().toList();
}
public List<TestBean> sortedTestBeans() {
return this.testBeanProvider.orderedStream().collect(Collectors.toList());
return this.testBeanProvider.orderedStream().toList();
}
}

6
spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java

@ -883,12 +883,12 @@ class BeanFactoryGenericsTests { @@ -883,12 +883,12 @@ class BeanFactoryGenericsTests {
assertThat(resolved.get(0)).isSameAs(bf.getBean("store1"));
assertThat(resolved.get(1)).isSameAs(bf.getBean("store2"));
resolved = numberStoreProvider.stream().collect(Collectors.toList());
resolved = numberStoreProvider.stream().toList();
assertThat(resolved.size()).isEqualTo(2);
assertThat(resolved.get(0)).isSameAs(bf.getBean("store1"));
assertThat(resolved.get(1)).isSameAs(bf.getBean("store2"));
resolved = numberStoreProvider.orderedStream().collect(Collectors.toList());
resolved = numberStoreProvider.orderedStream().toList();
assertThat(resolved.size()).isEqualTo(2);
assertThat(resolved.get(0)).isSameAs(bf.getBean("store2"));
assertThat(resolved.get(1)).isSameAs(bf.getBean("store1"));
@ -938,7 +938,7 @@ class BeanFactoryGenericsTests { @@ -938,7 +938,7 @@ class BeanFactoryGenericsTests {
bf.registerBeanDefinition("store2", bd2);
ObjectProvider<NumberStore<?>> numberStoreProvider = bf.getBeanProvider(ResolvableType.forClass(NumberStore.class));
List<NumberStore<?>> resolved = numberStoreProvider.orderedStream().collect(Collectors.toList());
List<NumberStore<?>> resolved = numberStoreProvider.orderedStream().toList();
assertThat(resolved.size()).isEqualTo(2);
assertThat(resolved.get(0)).isSameAs(bf.getBean("store2"));
assertThat(resolved.get(1)).isSameAs(bf.getBean("store1"));

3
spring-context-indexer/src/test/java/org/springframework/context/index/processor/Metadata.java

@ -18,7 +18,6 @@ package org.springframework.context.index.processor; @@ -18,7 +18,6 @@ package org.springframework.context.index.processor;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.assertj.core.api.Condition;
@ -30,7 +29,7 @@ import org.assertj.core.api.Condition; @@ -30,7 +29,7 @@ import org.assertj.core.api.Condition;
class Metadata {
public static Condition<CandidateComponentsMetadata> of(Class<?> type, Class<?>... stereotypes) {
return of(type.getName(), Arrays.stream(stereotypes).map(Class::getName).collect(Collectors.toList()));
return of(type.getName(), Arrays.stream(stereotypes).map(Class::getName).toList());
}
public static Condition<CandidateComponentsMetadata> of(String type, String... stereotypes) {

3
spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java vendored

@ -19,7 +19,6 @@ package org.springframework.cache.annotation; @@ -19,7 +19,6 @@ package org.springframework.cache.annotation;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
@ -77,7 +76,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware { @@ -77,7 +76,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
@Autowired
void setConfigurers(ObjectProvider<CachingConfigurer> configurers) {
Supplier<CachingConfigurer> configurer = () -> {
List<CachingConfigurer> candidates = configurers.stream().collect(Collectors.toList());
List<CachingConfigurer> candidates = configurers.stream().toList();
if (CollectionUtils.isEmpty(candidates)) {
return null;
}

3
spring-context/src/main/java/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.java

@ -20,7 +20,6 @@ import java.util.List; @@ -20,7 +20,6 @@ import java.util.List;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.ObjectProvider;
@ -72,7 +71,7 @@ public abstract class AbstractAsyncConfiguration implements ImportAware { @@ -72,7 +71,7 @@ public abstract class AbstractAsyncConfiguration implements ImportAware {
@Autowired
void setConfigurers(ObjectProvider<AsyncConfigurer> configurers) {
Supplier<AsyncConfigurer> configurer = SingletonSupplier.of(() -> {
List<AsyncConfigurer> candidates = configurers.stream().collect(Collectors.toList());
List<AsyncConfigurer> candidates = configurers.stream().toList();
if (CollectionUtils.isEmpty(candidates)) {
return null;
}

3
spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBeanMethodTests.java

@ -18,7 +18,6 @@ package org.springframework.context.annotation; @@ -18,7 +18,6 @@ package org.springframework.context.annotation;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
@ -156,7 +155,7 @@ class ConfigurationClassAndBeanMethodTests { @@ -156,7 +155,7 @@ class ConfigurationClassAndBeanMethodTests {
private static List<BeanMethod> getBeanMethods(ConfigurationClass configurationClass) {
List<BeanMethod> beanMethods = configurationClass.getBeanMethods().stream()
.sorted(Comparator.comparing(beanMethod -> beanMethod.getMetadata().getMethodName()))
.collect(Collectors.toList());
.toList();
assertThat(beanMethods).hasSize(3);
return beanMethods;
}

3
spring-context/src/testFixtures/java/org/springframework/context/testfixture/index/CandidateComponentsTestClassLoader.java

@ -20,7 +20,6 @@ import java.io.IOException; @@ -20,7 +20,6 @@ import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.context.index.CandidateComponentsIndexLoader;
@ -63,7 +62,7 @@ public class CandidateComponentsTestClassLoader extends ClassLoader { @@ -63,7 +62,7 @@ public class CandidateComponentsTestClassLoader extends ClassLoader {
catch (Exception ex) {
throw new IllegalArgumentException("Invalid resource " + r, ex);
}
}).collect(Collectors.toList())));
}).toList()));
}

5
spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java

@ -18,7 +18,6 @@ package org.springframework.aot.agent; @@ -18,7 +18,6 @@ package org.springframework.aot.agent;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.aot.hint.RuntimeHints;
@ -153,7 +152,7 @@ public final class RecordedInvocation { @@ -153,7 +152,7 @@ public final class RecordedInvocation {
* @return the argument types, starting at the given index
*/
public List<TypeReference> getArgumentTypes(int index) {
return Arrays.stream(this.arguments).skip(index).map(param -> TypeReference.of(param.getClass())).collect(Collectors.toList());
return Arrays.stream(this.arguments).skip(index).map(param -> TypeReference.of(param.getClass())).toList();
}
/**
@ -259,7 +258,7 @@ public final class RecordedInvocation { @@ -259,7 +258,7 @@ public final class RecordedInvocation {
public RecordedInvocation build() {
List<StackWalker.StackFrame> stackFrames = StackWalker.getInstance().walk(stream -> stream
.dropWhile(stackFrame -> stackFrame.getClassName().startsWith(getClass().getPackageName()))
.collect(Collectors.toList()));
.toList());
return new RecordedInvocation(this.instrumentedMethod, this.instance, this.arguments, this.returnValue, stackFrames);
}

2
spring-core/src/jmh/java/org/springframework/core/convert/support/GenericConversionServiceBenchmark.java

@ -66,7 +66,7 @@ public class GenericConversionServiceBenchmark { @@ -66,7 +66,7 @@ public class GenericConversionServiceBenchmark {
@Setup(Level.Trial)
public void setup() throws Exception {
this.source = IntStream.rangeClosed(1, collectionSize).mapToObj(String::valueOf).collect(Collectors.toList());
this.source = IntStream.rangeClosed(1, collectionSize).mapToObj(String::valueOf).toList();
List<Integer> target = new ArrayList<>();
this.targetTypeDesc = TypeDescriptor.forObject(target);
}

3
spring-core/src/main/java/org/springframework/core/KotlinReflectionParameterNameDiscoverer.java

@ -19,7 +19,6 @@ package org.springframework.core; @@ -19,7 +19,6 @@ package org.springframework.core;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;
import java.util.stream.Collectors;
import kotlin.reflect.KFunction;
import kotlin.reflect.KParameter;
@ -77,7 +76,7 @@ public class KotlinReflectionParameterNameDiscoverer implements ParameterNameDis @@ -77,7 +76,7 @@ public class KotlinReflectionParameterNameDiscoverer implements ParameterNameDis
.stream()
// Extension receivers of extension methods must be included as they appear as normal method parameters in Java
.filter(p -> KParameter.Kind.VALUE.equals(p.getKind()) || KParameter.Kind.EXTENSION_RECEIVER.equals(p.getKind()))
.collect(Collectors.toList());
.toList();
String[] parameterNames = new String[filteredParameters.size()];
for (int i = 0; i < filteredParameters.size(); i++) {
KParameter parameter = filteredParameters.get(i);

3
spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java

@ -29,7 +29,6 @@ import java.util.List; @@ -29,7 +29,6 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
import org.springframework.lang.Nullable;
@ -292,7 +291,7 @@ public abstract class MimeTypeUtils { @@ -292,7 +291,7 @@ public abstract class MimeTypeUtils {
return tokenize(mimeTypes).stream()
.filter(StringUtils::hasText)
.map(MimeTypeUtils::parseMimeType)
.collect(Collectors.toList());
.toList();
}
/**

5
spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java

@ -22,7 +22,6 @@ import java.lang.annotation.RetentionPolicy; @@ -22,7 +22,6 @@ import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
@ -95,7 +94,7 @@ class MergedAnnotationPredicatesTests { @@ -95,7 +94,7 @@ class MergedAnnotationPredicatesTests {
List<MergedAnnotation<TestAnnotation>> filtered = MergedAnnotations.from(
WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter(
MergedAnnotationPredicates.firstRunOf(
this::firstCharOfValue)).collect(Collectors.toList());
this::firstCharOfValue)).toList();
assertThat(filtered.stream().map(
annotation -> annotation.getString("value"))).containsExactly("a1", "a2", "a3");
}
@ -111,7 +110,7 @@ class MergedAnnotationPredicatesTests { @@ -111,7 +110,7 @@ class MergedAnnotationPredicatesTests {
List<MergedAnnotation<TestAnnotation>> filtered = MergedAnnotations.from(
WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter(
MergedAnnotationPredicates.unique(
this::firstCharOfValue)).collect(Collectors.toList());
this::firstCharOfValue)).toList();
assertThat(filtered.stream().map(
annotation -> annotation.getString("value"))).containsExactly("a1", "b1", "c1");
}

3
spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java

@ -33,7 +33,6 @@ import java.util.LinkedHashMap; @@ -33,7 +33,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jakarta.annotation.Resource;
@ -1896,7 +1895,7 @@ class MergedAnnotationsTests { @@ -1896,7 +1895,7 @@ class MergedAnnotationsTests {
Adapt.ANNOTATION_TO_MAP);
Map<String, Object>[] filters = (Map[]) map.get("excludeFilters");
List<String> patterns = Arrays.stream(filters).map(
m -> (String) m.get("pattern")).collect(Collectors.toList());
m -> (String) m.get("pattern")).toList();
assertThat(patterns).containsExactly("*Foo", "*Bar");
filters[0].put("pattern", "newFoo");
filters[0].put("enigma", 42);

3
spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBufferFactory.java

@ -22,7 +22,6 @@ import java.time.Instant; @@ -22,7 +22,6 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import io.netty.buffer.PooledByteBufAllocator;
import org.apache.commons.logging.Log;
@ -140,7 +139,7 @@ public class LeakAwareDataBufferFactory implements DataBufferFactory { @@ -140,7 +139,7 @@ public class LeakAwareDataBufferFactory implements DataBufferFactory {
// Remove LeakAwareDataBuffer wrapper so delegate can find native buffers
dataBuffers = dataBuffers.stream()
.map(o -> o instanceof LeakAwareDataBuffer ? ((LeakAwareDataBuffer) o).dataBuffer() : o)
.collect(Collectors.toList());
.toList();
return new LeakAwareDataBuffer(this.delegate.join(dataBuffers), this);
}

3
spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java

@ -26,7 +26,6 @@ import java.util.LinkedHashMap; @@ -26,7 +26,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -88,7 +87,7 @@ public abstract class TestPropertySourceUtils { @@ -88,7 +87,7 @@ public abstract class TestPropertySourceUtils {
// Convert all the merged annotations for the current aggregate
// level to a list of TestPropertySourceAttributes.
List<TestPropertySourceAttributes> aggregatedAttributesList =
aggregatedAnnotations.stream().map(TestPropertySourceAttributes::new).collect(Collectors.toList());
aggregatedAnnotations.stream().map(TestPropertySourceAttributes::new).toList();
// Merge all TestPropertySourceAttributes instances for the current
// aggregate level into a single TestPropertySourceAttributes instance.
TestPropertySourceAttributes mergedAttributes = mergeTestPropertySourceAttributes(aggregatedAttributesList);

6
spring-web/src/main/java/org/springframework/http/HttpHeaders.java

@ -486,7 +486,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable @@ -486,7 +486,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
range.getWeight() == Locale.LanguageRange.MAX_WEIGHT ?
range.getRange() :
range.getRange() + ";q=" + decimal.format(range.getWeight()))
.collect(Collectors.toList());
.toList();
set(ACCEPT_LANGUAGE, toCommaDelimitedString(values));
}
@ -511,7 +511,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable @@ -511,7 +511,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
public void setAcceptLanguageAsLocales(List<Locale> locales) {
setAcceptLanguage(locales.stream()
.map(locale -> new Locale.LanguageRange(locale.toLanguageTag()))
.collect(Collectors.toList()));
.toList());
}
/**
@ -529,7 +529,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable @@ -529,7 +529,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
return ranges.stream()
.map(range -> Locale.forLanguageTag(range.getRange()))
.filter(locale -> StringUtils.hasText(locale.getDisplayName()))
.collect(Collectors.toList());
.toList();
}
/**

3
spring-web/src/main/java/org/springframework/http/client/reactive/AbstractClientHttpRequest.java

@ -20,7 +20,6 @@ import java.util.ArrayList; @@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
@ -149,7 +148,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest { @@ -149,7 +148,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
}
List<? extends Publisher<Void>> actions = this.commitActions.stream()
.map(Supplier::get).collect(Collectors.toList());
.map(Supplier::get).toList();
return Flux.concat(actions).then();
}

3
spring-web/src/main/java/org/springframework/http/client/reactive/JettyHeadersAdapter.java

@ -23,7 +23,6 @@ import java.util.Iterator; @@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
@ -177,7 +176,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> { @@ -177,7 +176,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
@Override
public Collection<List<String>> values() {
return this.headers.getFieldNamesCollection().stream()
.map(this.headers::getValuesList).collect(Collectors.toList());
.map(this.headers::getValuesList).toList();
}
@Override

3
spring-web/src/main/java/org/springframework/http/client/reactive/Netty5HeadersAdapter.java

@ -22,7 +22,6 @@ import java.util.Iterator; @@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import io.netty5.handler.codec.http.HttpHeaders;
@ -165,7 +164,7 @@ class Netty5HeadersAdapter implements MultiValueMap<String, String> { @@ -165,7 +164,7 @@ class Netty5HeadersAdapter implements MultiValueMap<String, String> {
@Override
public Collection<List<String>> values() {
return this.headers.names().stream()
.map(this.headers::getAll).collect(Collectors.toList());
.map(this.headers::getAll).toList();
}
@Override

3
spring-web/src/main/java/org/springframework/http/client/reactive/NettyHeadersAdapter.java

@ -22,7 +22,6 @@ import java.util.Iterator; @@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import io.netty.handler.codec.http.HttpHeaders;
@ -164,7 +163,7 @@ class NettyHeadersAdapter implements MultiValueMap<String, String> { @@ -164,7 +163,7 @@ class NettyHeadersAdapter implements MultiValueMap<String, String> {
@Override
public Collection<List<String>> values() {
return this.headers.names().stream()
.map(this.headers::getAll).collect(Collectors.toList());
.map(this.headers::getAll).toList();
}
@Override

3
spring-web/src/main/java/org/springframework/http/codec/protobuf/ProtobufEncoder.java

@ -20,7 +20,6 @@ import java.io.IOException; @@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.google.protobuf.Message;
import org.reactivestreams.Publisher;
@ -61,7 +60,7 @@ public class ProtobufEncoder extends ProtobufCodecSupport implements HttpMessage @@ -61,7 +60,7 @@ public class ProtobufEncoder extends ProtobufCodecSupport implements HttpMessage
.stream()
.map(mimeType -> new MediaType(mimeType.getType(), mimeType.getSubtype(),
Collections.singletonMap(DELIMITED_KEY, DELIMITED_VALUE)))
.collect(Collectors.toList());
.toList();
@Override

3
spring-web/src/main/java/org/springframework/http/server/reactive/JettyHeadersAdapter.java

@ -23,7 +23,6 @@ import java.util.Iterator; @@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
@ -161,7 +160,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> { @@ -161,7 +160,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
@Override
public Collection<List<String>> values() {
return this.headers.getFieldNamesCollection().stream()
.map(this.headers::getValuesList).collect(Collectors.toList());
.map(this.headers::getValuesList).toList();
}
@Override

3
spring-web/src/main/java/org/springframework/http/server/reactive/Netty5HeadersAdapter.java

@ -22,7 +22,6 @@ import java.util.Iterator; @@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import io.netty5.handler.codec.http.HttpHeaders;
@ -163,7 +162,7 @@ final class Netty5HeadersAdapter implements MultiValueMap<String, String> { @@ -163,7 +162,7 @@ final class Netty5HeadersAdapter implements MultiValueMap<String, String> {
@Override
public Collection<List<String>> values() {
return this.headers.names().stream()
.map(this.headers::getAll).collect(Collectors.toList());
.map(this.headers::getAll).toList();
}
@Override

3
spring-web/src/main/java/org/springframework/http/server/reactive/NettyHeadersAdapter.java

@ -22,7 +22,6 @@ import java.util.Iterator; @@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import io.netty.handler.codec.http.HttpHeaders;
@ -163,7 +162,7 @@ final class NettyHeadersAdapter implements MultiValueMap<String, String> { @@ -163,7 +162,7 @@ final class NettyHeadersAdapter implements MultiValueMap<String, String> {
@Override
public Collection<List<String>> values() {
return this.headers.names().stream()
.map(this.headers::getAll).collect(Collectors.toList());
.map(this.headers::getAll).toList();
}
@Override

3
spring-web/src/main/java/org/springframework/http/server/reactive/TomcatHeadersAdapter.java

@ -24,7 +24,6 @@ import java.util.Iterator; @@ -24,7 +24,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.MimeHeaders;
@ -172,7 +171,7 @@ class TomcatHeadersAdapter implements MultiValueMap<String, String> { @@ -172,7 +171,7 @@ class TomcatHeadersAdapter implements MultiValueMap<String, String> {
@Override
public Collection<List<String>> values() {
return keySet().stream().map(this::get).collect(Collectors.toList());
return keySet().stream().map(this::get).toList();
}
@Override

3
spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java

@ -19,7 +19,6 @@ package org.springframework.web.bind.support; @@ -19,7 +19,6 @@ package org.springframework.web.bind.support;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;
@ -124,7 +123,7 @@ public class WebExchangeDataBinder extends WebDataBinder { @@ -124,7 +123,7 @@ public class WebExchangeDataBinder extends WebDataBinder {
if (!CollectionUtils.isEmpty(values)) {
values = values.stream()
.map(value -> value instanceof FormFieldPart ? ((FormFieldPart) value).value() : value)
.collect(Collectors.toList());
.toList();
params.put(key, values.size() == 1 ? values.get(0) : values);
}
}

3
spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

@ -25,7 +25,6 @@ import java.util.Collections; @@ -25,7 +25,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import io.micrometer.observation.Observation;
@ -971,7 +970,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat @@ -971,7 +970,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
.filter(converter -> canReadResponse(this.responseType, converter))
.flatMap((HttpMessageConverter<?> converter) -> getSupportedMediaTypes(this.responseType, converter))
.distinct()
.collect(Collectors.toList());
.toList();
MimeTypeUtils.sortBySpecificity(allSupportedMediaTypes);
if (logger.isDebugEnabled()) {
logger.debug("Accept=" + allSupportedMediaTypes);

7
spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java

@ -25,7 +25,6 @@ import java.util.Objects; @@ -25,7 +25,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
@ -136,7 +135,7 @@ public class CorsConfiguration { @@ -136,7 +135,7 @@ public class CorsConfiguration {
*/
public void setAllowedOrigins(@Nullable List<String> origins) {
this.allowedOrigins = (origins == null ? null :
origins.stream().filter(Objects::nonNull).map(this::trimTrailingSlash).collect(Collectors.toList()));
origins.stream().filter(Objects::nonNull).map(this::trimTrailingSlash).toList());
}
private String trimTrailingSlash(String origin) {
@ -212,7 +211,7 @@ public class CorsConfiguration { @@ -212,7 +211,7 @@ public class CorsConfiguration {
}
return this.allowedOriginPatterns.stream()
.map(OriginPattern::getDeclaredPattern)
.collect(Collectors.toList());
.toList();
}
/**
@ -445,7 +444,7 @@ public class CorsConfiguration { @@ -445,7 +444,7 @@ public class CorsConfiguration {
if (this.allowedMethods == null) {
this.allowedMethods = DEFAULT_PERMIT_METHODS;
this.resolvedMethods = DEFAULT_PERMIT_METHODS
.stream().map(HttpMethod::valueOf).collect(Collectors.toList());
.stream().map(HttpMethod::valueOf).toList();
}
if (this.allowedHeaders == null) {
this.allowedHeaders = DEFAULT_PERMIT_ALL;

7
spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java

@ -21,7 +21,6 @@ import java.util.Arrays; @@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import reactor.blockhound.BlockHound;
import reactor.blockhound.integration.BlockHoundIntegration;
@ -170,13 +169,13 @@ public final class WebHttpHandlerBuilder { @@ -170,13 +169,13 @@ public final class WebHttpHandlerBuilder {
List<WebFilter> webFilters = context
.getBeanProvider(WebFilter.class)
.orderedStream()
.collect(Collectors.toList());
.toList();
builder.filters(filters -> filters.addAll(webFilters));
List<WebExceptionHandler> exceptionHandlers = context
.getBeanProvider(WebExceptionHandler.class)
.orderedStream()
.collect(Collectors.toList());
.toList();
builder.exceptionHandlers(handlers -> handlers.addAll(exceptionHandlers));
context.getBeanProvider(HttpHandlerDecoratorFactory.class)
@ -253,7 +252,7 @@ public final class WebHttpHandlerBuilder { @@ -253,7 +252,7 @@ public final class WebHttpHandlerBuilder {
}
})
.filter(filter -> !(filter instanceof ForwardedHeaderTransformer))
.collect(Collectors.toList());
.toList();
this.filters.clear();
this.filters.addAll(filtersToUse);

3
spring-web/src/main/java/org/springframework/web/server/session/CookieWebSessionIdResolver.java

@ -20,7 +20,6 @@ import java.time.Duration; @@ -20,7 +20,6 @@ import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.springframework.http.HttpCookie;
import org.springframework.http.ResponseCookie;
@ -100,7 +99,7 @@ public class CookieWebSessionIdResolver implements WebSessionIdResolver { @@ -100,7 +99,7 @@ public class CookieWebSessionIdResolver implements WebSessionIdResolver {
if (cookies == null) {
return Collections.emptyList();
}
return cookies.stream().map(HttpCookie::getValue).collect(Collectors.toList());
return cookies.stream().map(HttpCookie::getValue).toList();
}
@Override

3
spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java

@ -27,7 +27,6 @@ import java.util.List; @@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
@ -523,7 +522,7 @@ class RestTemplateTests { @@ -523,7 +522,7 @@ class RestTemplateTests {
final List<List<String>> accepts = request.getHeaders().toMultimap().entrySet().stream()
.filter(entry -> entry.getKey().equalsIgnoreCase("accept"))
.map(Entry::getValue)
.collect(Collectors.toList());
.toList();
assertThat(accepts).hasSize(1);
assertThat(accepts.get(0)).hasSize(1);

3
spring-webflux/src/main/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilder.java

@ -23,7 +23,6 @@ import java.util.HashMap; @@ -23,7 +23,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
@ -88,7 +87,7 @@ public class RequestedContentTypeResolverBuilder { @@ -88,7 +87,7 @@ public class RequestedContentTypeResolverBuilder {
*/
public RequestedContentTypeResolver build() {
List<RequestedContentTypeResolver> resolvers = (!this.candidates.isEmpty() ?
this.candidates.stream().map(Supplier::get).collect(Collectors.toList()) :
this.candidates.stream().map(Supplier::get).toList() :
Collections.singletonList(new HeaderContentTypeResolver()));
return exchange -> {

3
spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurerComposite.java

@ -20,7 +20,6 @@ import java.util.ArrayList; @@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.codec.ServerCodecConfigurer;
@ -109,7 +108,7 @@ public class WebFluxConfigurerComposite implements WebFluxConfigurer { @@ -109,7 +108,7 @@ public class WebFluxConfigurerComposite implements WebFluxConfigurer {
@Nullable
private <T> T createSingleBean(Function<WebFluxConfigurer, T> factory, Class<T> beanType) {
List<T> result = this.delegates.stream().map(factory).filter(Objects::nonNull).collect(Collectors.toList());
List<T> result = this.delegates.stream().map(factory).filter(Objects::nonNull).toList();
if (result.isEmpty()) {
return null;
}

3
spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java

@ -20,7 +20,6 @@ import java.util.List; @@ -20,7 +20,6 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
@ -203,7 +202,7 @@ public abstract class BodyExtractors { @@ -203,7 +202,7 @@ public abstract class BodyExtractors {
.orElseGet(() -> {
List<MediaType> mediaTypes = context.messageReaders().stream()
.flatMap(reader -> reader.getReadableMediaTypes(elementType).stream())
.collect(Collectors.toList());
.toList();
return errorFunction.apply(
new UnsupportedMediaTypeException(contentType, mediaTypes, elementType));
});

3
spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
package org.springframework.web.reactive.function;
import java.util.List;
import java.util.stream.Collectors;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;
@ -386,7 +385,7 @@ public abstract class BodyInserters { @@ -386,7 +385,7 @@ public abstract class BodyInserters {
List<MediaType> supportedMediaTypes = context.messageWriters().stream()
.flatMap(reader -> reader.getWritableMediaTypes(bodyType).stream())
.collect(Collectors.toList());
.toList();
return new UnsupportedMediaTypeException(mediaType, supportedMediaTypes, bodyType);
}

3
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java

@ -30,7 +30,6 @@ import java.util.function.Function; @@ -30,7 +30,6 @@ import java.util.function.Function;
import java.util.function.IntPredicate;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;
@ -122,7 +121,7 @@ class DefaultWebClient implements WebClient { @@ -122,7 +121,7 @@ class DefaultWebClient implements WebClient {
return (CollectionUtils.isEmpty(handlerMap) ? Collections.emptyList() :
handlerMap.entrySet().stream()
.map(entry -> new DefaultResponseSpec.StatusHandler(entry.getKey(), entry.getValue()))
.collect(Collectors.toList()));
.toList());
};

3
spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java

@ -27,7 +27,6 @@ import java.util.List; @@ -27,7 +27,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -359,7 +358,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean { @@ -359,7 +358,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
}
if (isOptimizeLocations()) {
result = result.stream().filter(Resource::exists).collect(Collectors.toList());
result = result.stream().filter(Resource::exists).toList();
}
this.locationsToUse.clear();

2
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java

@ -300,7 +300,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe @@ -300,7 +300,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
return this.partialMatches.stream()
.filter(PartialMatch::hasProducesMatch)
.map(match -> match.getInfo().getParamsCondition().getExpressions())
.collect(Collectors.toList());
.toList();
}
/**

3
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncInvocableHandlerMethod.java

@ -20,7 +20,6 @@ import java.lang.reflect.Method; @@ -20,7 +20,6 @@ import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.ParameterNameDiscoverer;
@ -69,7 +68,7 @@ public class SyncInvocableHandlerMethod extends HandlerMethod { @@ -69,7 +68,7 @@ public class SyncInvocableHandlerMethod extends HandlerMethod {
public List<SyncHandlerMethodArgumentResolver> getResolvers() {
return this.delegate.getResolvers().stream()
.map(resolver -> (SyncHandlerMethodArgumentResolver) resolver)
.collect(Collectors.toList());
.toList();
}
/**

7
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java

@ -24,7 +24,6 @@ import java.util.List; @@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -133,9 +132,9 @@ class ControllerMethodResolver { @@ -133,9 +132,9 @@ class ControllerMethodResolver {
ConfigurableApplicationContext context) {
return initResolvers(customResolvers, adapterRegistry, context, false, Collections.emptyList()).stream()
.filter(resolver -> resolver instanceof SyncHandlerMethodArgumentResolver)
.map(resolver -> (SyncHandlerMethodArgumentResolver) resolver)
.collect(Collectors.toList());
.filter(SyncHandlerMethodArgumentResolver.class::isInstance)
.map(SyncHandlerMethodArgumentResolver.class::cast)
.toList();
}
private static List<HandlerMethodArgumentResolver> modelMethodResolvers(

3
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelInitializer.java

@ -21,7 +21,6 @@ import java.util.Arrays; @@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;
@ -112,7 +111,7 @@ class ModelInitializer { @@ -112,7 +111,7 @@ class ModelInitializer {
.zip(resultList, objectArray ->
Arrays.stream(objectArray)
.map(object -> handleResult(((HandlerResult) object), bindingContext))
.collect(Collectors.toList()))
.toList())
.flatMap(Mono::when);
}

3
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java

@ -23,7 +23,6 @@ import java.util.List; @@ -23,7 +23,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -357,7 +356,7 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport imp @@ -357,7 +356,7 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport imp
private List<MediaType> getMediaTypes(List<View> views) {
return views.stream()
.flatMap(view -> view.getSupportedMediaTypes().stream())
.collect(Collectors.toList());
.toList();
}
}

3
spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java

@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.condition; @@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.condition;
import java.util.Arrays;
import java.util.Iterator;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
@ -210,7 +209,7 @@ public class PatternsRequestConditionTests { @@ -210,7 +209,7 @@ public class PatternsRequestConditionTests {
return new PatternsRequestCondition(Arrays
.stream(patterns)
.map(this.parser::parse)
.collect(Collectors.toList()));
.toList());
}
}

3
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java

@ -21,7 +21,6 @@ import java.time.Duration; @@ -21,7 +21,6 @@ import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import io.reactivex.rxjava3.core.Single;
import org.junit.jupiter.api.BeforeEach;
@ -208,7 +207,7 @@ public class ModelInitializerTests { @@ -208,7 +207,7 @@ public class ModelInitializerTests {
MethodIntrospector.selectMethods(controller.getClass(), BINDER_METHODS)
.stream()
.map(method -> new SyncInvocableHandlerMethod(controller, method))
.collect(Collectors.toList());
.toList();
WebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
return new InitBinderBindingContext(bindingInitializer, binderMethods);

3
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistry.java

@ -19,7 +19,6 @@ package org.springframework.web.servlet.config.annotation; @@ -19,7 +19,6 @@ package org.springframework.web.servlet.config.annotation;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered;
@ -71,7 +70,7 @@ public class InterceptorRegistry { @@ -71,7 +70,7 @@ public class InterceptorRegistry {
return this.registrations.stream()
.sorted(INTERCEPTOR_ORDER_COMPARATOR)
.map(InterceptorRegistration::getInterceptor)
.collect(Collectors.toList());
.toList();
}

3
spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultEntityResponseBuilder.java

@ -28,7 +28,6 @@ import java.util.Set; @@ -28,7 +28,6 @@ import java.util.Set;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
@ -336,7 +335,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T> @@ -336,7 +335,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T>
return messageConverters.stream()
.filter(messageConverter -> messageConverter.canWrite(entityClass, null))
.flatMap(messageConverter -> messageConverter.getSupportedMediaTypes(entityClass).stream())
.collect(Collectors.toList());
.toList();
}
}

3
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java

@ -25,7 +25,6 @@ import java.util.HashMap; @@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
@ -490,7 +489,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator @@ -490,7 +489,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
result.addAll(this.locationResources);
if (isOptimizeLocations()) {
result = result.stream().filter(Resource::exists).collect(Collectors.toList());
result = result.stream().filter(Resource::exists).toList();
}
this.locationsToUse.clear();

3
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java

@ -26,7 +26,6 @@ import java.util.Map; @@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -413,7 +412,7 @@ public abstract class AbstractSockJsSession implements SockJsSession { @@ -413,7 +412,7 @@ public abstract class AbstractSockJsSession implements SockJsSession {
Collections.<String>emptyList() : Collections.singletonList(messages[i]));
default -> Arrays.stream(Arrays.copyOfRange(messages, i, messages.length))
.filter(message -> !message.trim().isEmpty())
.collect(Collectors.toList());
.toList();
};
}

Loading…
Cancel
Save