From e0b67889a8f70228227e06732f9973a1e9bc1a86 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 4 Oct 2022 00:26:51 -0700 Subject: [PATCH] Use Stream.toList instead of Stream.collect when possible Update code to make use of `Stream.toList()` whenever possible. Closes gh-28177 --- .../AutoConfigurationMetadata.java | 4 +-- .../boot/build/bom/BomExtension.java | 3 +-- .../boot/build/bom/BomPlugin.java | 4 +-- .../bom/bomr/InteractiveUpgradeResolver.java | 13 +++++---- .../boot/build/bom/bomr/UpgradeBom.java | 3 +-- .../bomr/github/StandardGitHubRepository.java | 4 +-- ...heckClasspathForUnnecessaryExclusions.java | 3 +-- ...AdditionalSpringConfigurationMetadata.java | 3 +-- .../CheckSpringConfigurationMetadata.java | 4 +-- .../mavenplugin/DocumentPluginGoals.java | 11 +++----- .../build/testing/TestResultsOverview.java | 4 +-- .../mavenplugin/PluginXmlParserTests.java | 7 +++-- .../TestFailuresPluginIntegrationTests.java | 3 +-- ...CloudFoundryActuatorAutoConfiguration.java | 3 +-- ...CloudFoundryActuatorAutoConfiguration.java | 3 +-- .../endpoint/EndpointAutoConfiguration.java | 6 ++--- .../jmx/JmxEndpointAutoConfiguration.java | 5 +--- .../web/WebEndpointAutoConfiguration.java | 14 ++++------ ...ndpointManagementContextConfiguration.java | 3 +-- ...althEndpointWebExtensionConfiguration.java | 3 +-- .../info/InfoEndpointAutoConfiguration.java | 4 +-- ...rceHealthContributorAutoConfiguration.java | 2 +- .../metrics/MeterRegistryConfigurer.java | 11 ++------ .../metrics/PropertiesMeterFilter.java | 11 +++++--- .../GraphQlMetricsAutoConfiguration.java | 4 +-- ...ataSourcePoolMetricsAutoConfiguration.java | 4 +-- .../WebFluxMetricsAutoConfiguration.java | 4 +-- .../WebMvcMetricsAutoConfiguration.java | 4 +-- ...heduledTasksEndpointAutoConfiguration.java | 4 +-- .../security/reactive/EndpointRequest.java | 7 +++-- .../security/servlet/EndpointRequest.java | 2 +- .../OpenTelemetryAutoConfiguration.java | 11 ++++---- .../MappingsEndpointAutoConfiguration.java | 5 +--- .../ManagementWebServerFactoryCustomizer.java | 26 +++++++----------- ...FoundryActuatorAutoConfigurationTests.java | 6 ++--- .../WebEndpointAutoConfigurationTests.java | 6 ++--- .../AbstractEndpointDocumentationTests.java | 10 +++---- ...mentWebSecurityAutoConfigurationTests.java | 3 +-- ...ntextConfigurationImportSelectorTests.java | 3 +-- .../boot/actuate/cache/CachesEndpoint.java | 11 +++----- .../actuate/couchbase/CouchbaseHealth.java | 5 ++-- .../annotation/EndpointDiscoverer.java | 7 +++-- .../endpoint/jmx/JmxEndpointExporter.java | 5 ++-- .../annotation/DiscoveredJmxOperation.java | 11 +++----- .../endpoint/web/PathMappedEndpoints.java | 10 ++----- .../boot/actuate/flyway/FlywayEndpoint.java | 3 +-- .../health/SimpleStatusAggregator.java | 5 ++-- .../actuate/liquibase/LiquibaseEndpoint.java | 6 ++--- .../PlainTextThreadDumpFormatter.java | 6 ++--- .../boot/actuate/metrics/MetricsEndpoint.java | 9 ++----- .../boot/actuate/quartz/QuartzEndpoint.java | 5 ++-- .../actuate/session/SessionsEndpoint.java | 5 ++-- ...herHandlersMappingDescriptionProvider.java | 7 +++-- .../RequestMappingConditionsDescription.java | 13 ++++----- ...herServletsMappingDescriptionProvider.java | 7 +++-- .../FiltersMappingDescriptionProvider.java | 3 +-- .../RequestMappingConditionsDescription.java | 11 ++++---- .../ServletsMappingDescriptionProvider.java | 3 +-- .../actuate/beans/BeansEndpointTests.java | 5 ++-- .../OperationMethodParametersTests.java | 5 ++-- .../ControllerEndpointDiscovererTests.java | 4 +-- .../ServletEndpointDiscovererTests.java | 4 +-- .../WebEndpointDiscovererTests.java | 3 +-- .../DefaultWebMvcTagsProviderTests.java | 4 +-- ...EndpointTestInvocationContextProvider.java | 3 ++- .../info/InfoEndpointWebIntegrationTests.java | 5 ++-- .../DefaultWebFluxTagsProviderTests.java | 4 +-- .../AutoConfigurationImportSelector.java | 3 +-- .../autoconfigure/AutoConfigurations.java | 4 +-- .../RabbitAnnotationDrivenConfiguration.java | 10 +++---- .../amqp/RabbitAutoConfiguration.java | 5 +--- .../cache/CacheAutoConfiguration.java | 4 +-- .../cassandra/CassandraAutoConfiguration.java | 4 +-- .../condition/OnPropertyCondition.java | 3 +-- .../NoSuchBeanDefinitionFailureAnalyzer.java | 3 +-- .../flyway/FlywayAutoConfiguration.java | 10 +++---- .../graphql/GraphQlAutoConfiguration.java | 11 +++----- ...raphQlQuerydslSourceBuilderCustomizer.java | 17 ++++-------- .../GraphQlWebFluxAutoConfiguration.java | 6 ++--- .../GraphQlRSocketAutoConfiguration.java | 10 +++---- .../GraphQlWebMvcAutoConfiguration.java | 6 ++--- .../h2/H2ConsoleAutoConfiguration.java | 27 +++++++++---------- ...ttpMessageConvertersAutoConfiguration.java | 4 +-- .../ArtemisEmbeddedServerConfiguration.java | 13 ++------- .../ConditionEvaluationReportMessage.java | 5 ++-- .../mongo/MongoAutoConfiguration.java | 5 +--- .../mongo/MongoReactiveAutoConfiguration.java | 4 +-- .../neo4j/Neo4jAutoConfiguration.java | 4 +-- .../orm/jpa/HibernateJpaConfiguration.java | 5 ++-- .../ConnectionFactoryConfigurations.java | 7 +++-- .../RSocketServerAutoConfiguration.java | 4 +-- .../RSocketWebSocketNettyRouteProvider.java | 5 ++-- .../reactive/StaticResourceRequest.java | 15 +++++------ ...RelyingPartyRegistrationConfiguration.java | 3 +-- .../servlet/StaticResourceRequest.java | 10 +++---- .../TransactionAutoConfiguration.java | 4 +-- .../client/RestTemplateAutoConfiguration.java | 7 ++--- ...ReactiveWebServerFactoryConfiguration.java | 19 +++++-------- .../error/ErrorWebFluxAutoConfiguration.java | 4 +-- .../client/WebClientAutoConfiguration.java | 4 +-- ...vletWebServerFactoryAutoConfiguration.java | 6 ++--- .../ServletWebServerFactoryConfiguration.java | 18 +++++-------- .../error/ErrorMvcAutoConfiguration.java | 3 +-- .../WebServiceTemplateAutoConfiguration.java | 4 +-- ...aSourceScriptDatabaseInitializerTests.java | 3 +-- .../http/HttpMessageConvertersTests.java | 5 ++-- .../OAuth2WebSecurityConfigurationTests.java | 3 +-- .../JettyWebServerFactoryCustomizerTests.java | 4 +-- .../tests/AbstractApplicationLauncher.java | 6 ++--- .../livereload/LiveReloadServerTests.java | 8 +++--- .../WebTestClientAutoConfiguration.java | 4 +-- .../context/SpringBootContextLoaderTests.java | 3 ++- .../web/client/TestRestTemplateTests.java | 12 ++++----- .../buildpack/platform/docker/type/Image.java | 5 ++-- .../infrastructure/CommandLineInvoker.java | 5 ++-- ...onstructorParameterPropertyDescriptor.java | 4 +-- .../PropertyDescriptorResolver.java | 3 +-- .../metadata/JsonConverter.java | 5 ++-- ...uctorParameterPropertyDescriptorTests.java | 3 +-- .../MergeMetadataGenerationTests.java | 3 +-- .../metadata/Metadata.java | 4 +-- .../gradle/tasks/bundling/BootBuildImage.java | 7 +++-- .../tasks/bundling/BootZipCopyAction.java | 6 ++--- .../gradle/tasks/bundling/LayeredSpec.java | 12 ++++----- .../AbstractBootArchiveIntegrationTests.java | 6 ++--- .../bundling/AbstractBootArchiveTests.java | 3 +-- .../boot/loader/tools/Packager.java | 3 +-- .../layer/IncludeExcludeContentSelector.java | 5 ++-- .../loader/tools/AbstractPackagerTests.java | 7 ++--- .../boot/loader/ClassPathIndexFile.java | 7 +++-- .../loader/jar/JarURLConnectionTests.java | 5 ++-- .../AbstractArchiveIntegrationTests.java | 7 ++--- .../boot/maven/JarIntegrationTests.java | 4 +-- .../boot/maven/WarIntegrationTests.java | 4 +-- .../boot/maven/CustomLayersProvider.java | 10 +++---- .../org/springframework/boot/maven/Image.java | 10 +++---- .../migrator/PropertiesMigrationReport.java | 7 +++-- .../boot/SpringApplication.java | 3 +-- .../ConfigDataEnvironmentContributors.java | 3 +-- .../config/ConfigDataLocationBindHandler.java | 4 ++- .../ConfigurationPropertiesBinder.java | 3 +-- .../boot/diagnostics/FailureAnalyzers.java | 8 +++--- ...igurationPropertyValueFailureAnalyzer.java | 3 +-- ...onfigurationPropertiesFailureAnalyzer.java | 3 +-- .../boot/env/OriginTrackedYamlLoader.java | 3 +-- .../logging/log4j2/Log4J2LoggingSystem.java | 4 +-- .../boot/util/Instantiator.java | 3 ++- ...FilteredMethodValidationPostProcessor.java | 5 ++-- .../embedded/netty/CompressionCustomizer.java | 6 ++--- .../ServletContextInitializerBeans.java | 6 ++--- .../config/ConfigDataEnvironmentTests.java | 3 +-- .../bind/CollectionBinderTests.java | 5 ++-- .../properties/bind/MapBinderTests.java | 4 +-- .../ConfigurationPropertyNameTests.java | 5 ++-- ...rrentlyInCreationFailureAnalyzerTests.java | 3 +-- .../boot/jackson/JsonMixinModuleTests.java | 4 +-- ...itializationDependencyConfigurerTests.java | 10 +++---- ...ntainerWarDevelopmentIntegrationTests.java | 5 ++-- ...ContainerWarPackagingIntegrationTests.java | 5 ++-- 159 files changed, 349 insertions(+), 607 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java index 5b3f29b62a..02275a6baf 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Properties; import java.util.Set; import java.util.concurrent.Callable; -import java.util.stream.Collectors; import org.gradle.api.DefaultTask; import org.gradle.api.Task; @@ -124,8 +123,7 @@ public class AutoConfigurationMetadata extends DefaultTask { return Collections.emptyList(); } try (BufferedReader reader = new BufferedReader(new FileReader(file))) { - return reader.lines().map(this::stripComment).filter((line) -> !line.isEmpty()) - .collect(Collectors.toList()); + return reader.lines().map(this::stripComment).filter((line) -> !line.isEmpty()).toList(); } } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomExtension.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomExtension.java index a4cafad9f9..6107e6b444 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomExtension.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomExtension.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.inject.Inject; import javax.xml.parsers.DocumentBuilderFactory; @@ -301,7 +300,7 @@ public class BomExtension { public void setModules(List modules) { this.modules = modules.stream() .map((input) -> (input instanceof Module module) ? module : new Module((String) input)) - .collect(Collectors.toList()); + .toList(); } public void setImports(List imports) { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java index 2f273b219c..39e94996ac 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java @@ -269,9 +269,7 @@ public class BomPlugin implements Plugin { @SuppressWarnings("unchecked") private List findChildren(Node parent, String name) { - return (List) parent.children().stream().filter((child) -> isNodeWithName(child, name)) - .collect(Collectors.toList()); - + return parent.children().stream().filter((child) -> isNodeWithName(child, name)).toList(); } private boolean isNodeWithName(Object candidate, String name) { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/InteractiveUpgradeResolver.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/InteractiveUpgradeResolver.java index 064e0905f3..81ea03d113 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/InteractiveUpgradeResolver.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/InteractiveUpgradeResolver.java @@ -27,7 +27,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.SortedSet; -import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.gradle.api.InvalidUserDataException; @@ -71,8 +71,7 @@ public final class InteractiveUpgradeResolver implements UpgradeResolver { librariesByName.put(library.getName(), library); } return librariesToUpgrade.stream().filter((library) -> !library.getName().equals("Spring Boot")) - .map((library) -> resolveUpgrade(library, librariesByName)).filter(Objects::nonNull) - .collect(Collectors.toList()); + .map((library) -> resolveUpgrade(library, librariesByName)).filter(Objects::nonNull).toList(); } private Upgrade resolveUpgrade(Library library, Map libraries) { @@ -112,13 +111,13 @@ public final class InteractiveUpgradeResolver implements UpgradeResolver { } List allVersions = moduleVersions.values().stream().flatMap(SortedSet::stream).distinct() .filter((dependencyVersion) -> isPermitted(dependencyVersion, library.getProhibitedVersions())) - .collect(Collectors.toList()); + .toList(); if (allVersions.isEmpty()) { return Collections.emptyList(); } - return allVersions.stream() - .map((version) -> new ResolvedVersionOption(version, getMissingModules(moduleVersions, version))) - .collect(Collectors.toList()); + Stream resolvedVersionOptions = allVersions.stream() + .map((version) -> new ResolvedVersionOption(version, getMissingModules(moduleVersions, version))); + return resolvedVersionOptions.toList(); } private List determineAlignedVersionOption(Library library, Map libraries) { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java index 8a38fce9be..d1b400385b 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeBom.java @@ -30,7 +30,6 @@ import java.util.Properties; import java.util.Set; import java.util.function.Predicate; import java.util.regex.Pattern; -import java.util.stream.Collectors; import javax.inject.Inject; @@ -163,7 +162,7 @@ public class UpgradeBom extends DefaultTask { } Predicate libraryPredicate = Pattern.compile(pattern).asPredicate(); List matchingLibraries = this.bom.getLibraries().stream() - .filter((library) -> libraryPredicate.test(library.getName())).collect(Collectors.toList()); + .filter((library) -> libraryPredicate.test(library.getName())).toList(); if (matchingLibraries.isEmpty()) { throw new InvalidUserDataException("No libraries matched '" + pattern + "'"); } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHubRepository.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHubRepository.java index 73aa7435b0..be1d9b4818 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHubRepository.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHubRepository.java @@ -20,7 +20,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.stream.Collectors; import org.springframework.http.ResponseEntity; import org.springframework.web.client.HttpClientErrorException.Forbidden; @@ -92,8 +91,7 @@ final class StandardGitHubRepository implements GitHubRepository { @SuppressWarnings({ "rawtypes", "unchecked" }) private List get(String name, Function, T> mapper) { ResponseEntity response = this.rest.getForEntity(name, List.class); - List> body = response.getBody(); - return body.stream().map(mapper).collect(Collectors.toList()); + return ((List>) response.getBody()).stream().map(mapper).toList(); } } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java index e2ecbf1765..a97bf106df 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java @@ -106,8 +106,7 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask { if (!exclusions.isEmpty()) { Dependency toCheck = this.dependencyById.get(dependencyId); List dependencies = this.configurations.detachedConfiguration(toCheck, this.platform) - .getIncoming().getArtifacts().getArtifacts().stream().map(this::getId) - .collect(Collectors.toList()); + .getIncoming().getArtifacts().getArtifacts().stream().map(this::getId).toList(); exclusions.removeAll(dependencies); removeProfileExclusions(dependencyId, exclusions); if (!exclusions.isEmpty()) { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckAdditionalSpringConfigurationMetadata.java b/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckAdditionalSpringConfigurationMetadata.java index b95e8e0a42..d45b1d4e92 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckAdditionalSpringConfigurationMetadata.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckAdditionalSpringConfigurationMetadata.java @@ -27,7 +27,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -95,7 +94,7 @@ public class CheckAdditionalSpringConfigurationMetadata extends SourceTask { @SuppressWarnings("unchecked") private void check(String key, Map json, Analysis analysis) { List> groups = (List>) json.get(key); - List names = groups.stream().map((group) -> (String) group.get("name")).collect(Collectors.toList()); + List names = groups.stream().map((group) -> (String) group.get("name")).toList(); List sortedNames = sortedCopy(names); for (int i = 0; i < names.size(); i++) { String actual = names.get(i); diff --git a/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckSpringConfigurationMetadata.java b/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckSpringConfigurationMetadata.java index a41d1448c7..8a5028baa5 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckSpringConfigurationMetadata.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/context/properties/CheckSpringConfigurationMetadata.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -154,8 +153,7 @@ public class CheckSpringConfigurationMetadata extends DefaultTask { else { lines.add("The following properties have no description:"); lines.add(""); - lines.addAll(this.propertiesWithNoDescription.stream().map((line) -> "\t" + line) - .collect(Collectors.toList())); + lines.addAll(this.propertiesWithNoDescription.stream().map((line) -> "\t" + line).toList()); } lines.add(""); return lines.iterator(); diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/DocumentPluginGoals.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/DocumentPluginGoals.java index 58c41fa29d..954f9467a7 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/DocumentPluginGoals.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/DocumentPluginGoals.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.List; -import java.util.stream.Collectors; import org.gradle.api.DefaultTask; import org.gradle.api.Task; @@ -98,10 +97,8 @@ public class DocumentPluginGoals extends DefaultTask { writer.printf("`%s:%s:%s`%n", plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion()); writer.println(); writer.println(mojo.getDescription()); - List parameters = mojo.getParameters().stream().filter(Parameter::isEditable) - .collect(Collectors.toList()); - List requiredParameters = parameters.stream().filter(Parameter::isRequired) - .collect(Collectors.toList()); + List parameters = mojo.getParameters().stream().filter(Parameter::isEditable).toList(); + List requiredParameters = parameters.stream().filter(Parameter::isRequired).toList(); String parametersSectionId = sectionId + "-parameters"; String detailsSectionId = parametersSectionId + "-details"; if (!requiredParameters.isEmpty()) { @@ -112,7 +109,7 @@ public class DocumentPluginGoals extends DefaultTask { writeParametersTable(writer, detailsSectionId, requiredParameters); } List optionalParameters = parameters.stream().filter((parameter) -> !parameter.isRequired()) - .collect(Collectors.toList()); + .toList(); if (!optionalParameters.isEmpty()) { writer.println(); writer.println(); diff --git a/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java b/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java index 545e8c9086..b656a6c3a0 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java @@ -19,7 +19,6 @@ package org.springframework.boot.build.testing; import java.util.List; import java.util.Map; import java.util.TreeMap; -import java.util.stream.Collectors; import org.gradle.api.services.BuildService; import org.gradle.api.services.BuildServiceParameters; @@ -42,8 +41,7 @@ public abstract class TestResultsOverview private final Object monitor = new Object(); void addFailures(Test test, List failureDescriptors) { - List testFailures = failureDescriptors.stream().map(TestFailure::new).sorted() - .collect(Collectors.toList()); + List testFailures = failureDescriptors.stream().map(TestFailure::new).sorted().toList(); synchronized (this.monitor) { this.testFailures.put(test, testFailures); } diff --git a/buildSrc/src/test/java/org/springframework/boot/build/mavenplugin/PluginXmlParserTests.java b/buildSrc/src/test/java/org/springframework/boot/build/mavenplugin/PluginXmlParserTests.java index e5753824b9..4333aa83f8 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/mavenplugin/PluginXmlParserTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/mavenplugin/PluginXmlParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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.boot.build.mavenplugin; import java.io.File; import java.io.FileNotFoundException; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -44,8 +43,8 @@ class PluginXmlParserTests { assertThat(plugin.getArtifactId()).isEqualTo("spring-boot-maven-plugin"); assertThat(plugin.getVersion()).isEqualTo("2.2.0.GRADLE-SNAPSHOT"); assertThat(plugin.getGoalPrefix()).isEqualTo("spring-boot"); - assertThat(plugin.getMojos().stream().map(PluginXmlParser.Mojo::getGoal).collect(Collectors.toList())) - .containsExactly("build-info", "help", "repackage", "run", "start", "stop"); + assertThat(plugin.getMojos().stream().map(PluginXmlParser.Mojo::getGoal)).containsExactly("build-info", "help", + "repackage", "run", "start", "stop"); } @Test diff --git a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java index a3088d59e6..9b63eae5d6 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java @@ -24,7 +24,6 @@ import java.io.PrintWriter; import java.io.StringReader; import java.util.List; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.GradleRunner; @@ -170,7 +169,7 @@ class TestFailuresPluginIntegrationTests { private List readLines(String output) { try (BufferedReader reader = new BufferedReader(new StringReader(output))) { - return reader.lines().collect(Collectors.toList()); + return reader.lines().toList(); } catch (IOException ex) { throw new RuntimeException(ex); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java index 6e92fc85cd..ca6478a457 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectProvider; @@ -99,7 +98,7 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration { List contributors = infoContributors.orderedStream() .map((infoContributor) -> (infoContributor instanceof GitInfoContributor) ? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor) - .collect(Collectors.toList()); + .toList(); return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java index a9f3293776..cf588469dd 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer; @@ -103,7 +102,7 @@ public class CloudFoundryActuatorAutoConfiguration { List contributors = infoContributors.orderedStream() .map((infoContributor) -> (infoContributor instanceof GitInfoContributor) ? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor) - .collect(Collectors.toList()); + .toList(); return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.java index a7bcd2f262..6448366a80 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.java @@ -17,7 +17,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; @@ -52,9 +51,8 @@ public class EndpointAutoConfiguration { public ParameterValueMapper endpointOperationParameterMapper( @EndpointConverter ObjectProvider> converters, @EndpointConverter ObjectProvider genericConverters) { - ConversionService conversionService = createConversionService( - converters.orderedStream().collect(Collectors.toList()), - genericConverters.orderedStream().collect(Collectors.toList())); + ConversionService conversionService = createConversionService(converters.orderedStream().toList(), + genericConverters.orderedStream().toList()); return new ConversionServiceParameterValueMapper(conversionService); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java index 28ae06d075..472a8d7009 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.jmx; -import java.util.stream.Collectors; - import javax.management.MBeanServer; import com.fasterxml.jackson.databind.ObjectMapper; @@ -84,8 +82,7 @@ public class JmxEndpointAutoConfiguration { ObjectProvider invokerAdvisors, ObjectProvider> filters) { return new JmxEndpointDiscoverer(this.applicationContext, parameterValueMapper, - invokerAdvisors.orderedStream().collect(Collectors.toList()), - filters.orderedStream().collect(Collectors.toList())); + invokerAdvisors.orderedStream().toList(), filters.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java index a9cad4f084..66f1c43df2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web; import java.util.Collection; import java.util.Collections; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; @@ -91,17 +90,15 @@ public class WebEndpointAutoConfiguration { ObjectProvider invokerAdvisors, ObjectProvider> filters) { return new WebEndpointDiscoverer(this.applicationContext, parameterValueMapper, endpointMediaTypes, - endpointPathMappers.orderedStream().collect(Collectors.toList()), - invokerAdvisors.orderedStream().collect(Collectors.toList()), - filters.orderedStream().collect(Collectors.toList())); + endpointPathMappers.orderedStream().toList(), invokerAdvisors.orderedStream().toList(), + filters.orderedStream().toList()); } @Bean @ConditionalOnMissingBean(ControllerEndpointsSupplier.class) public ControllerEndpointDiscoverer controllerEndpointDiscoverer(ObjectProvider endpointPathMappers, ObjectProvider>> filters) { - return new ControllerEndpointDiscoverer(this.applicationContext, - endpointPathMappers.orderedStream().collect(Collectors.toList()), + return new ControllerEndpointDiscoverer(this.applicationContext, endpointPathMappers.orderedStream().toList(), filters.getIfAvailable(Collections::emptyList)); } @@ -134,9 +131,8 @@ public class WebEndpointAutoConfiguration { ServletEndpointDiscoverer servletEndpointDiscoverer(ApplicationContext applicationContext, ObjectProvider endpointPathMappers, ObjectProvider> filters) { - return new ServletEndpointDiscoverer(applicationContext, - endpointPathMappers.orderedStream().collect(Collectors.toList()), - filters.orderedStream().collect(Collectors.toList())); + return new ServletEndpointDiscoverer(applicationContext, endpointPathMappers.orderedStream().toList(), + filters.orderedStream().toList()); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java index 5bac6e79a9..0ca941a499 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.model.Resource; @@ -183,7 +182,7 @@ class JerseyWebEndpointManagementContextConfiguration { WebServerNamespace.MANAGEMENT, this.groups); Collection endpointResources = resourceFactory .createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false) - .stream().filter(Objects::nonNull).collect(Collectors.toList()); + .stream().filter(Objects::nonNull).toList(); register(endpointResources, config); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java index 857b628295..e81fbad461 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionConfiguration.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Objects; -import java.util.stream.Collectors; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.model.Resource; @@ -162,7 +161,7 @@ class HealthEndpointWebExtensionConfiguration { WebServerNamespace.SERVER, this.groups); Collection endpointResources = resourceFactory .createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false) - .stream().filter(Objects::nonNull).collect(Collectors.toList()); + .stream().filter(Objects::nonNull).toList(); register(endpointResources, config); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.java index f61eb91a7e..72f854dab4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.info; -import java.util.stream.Collectors; - import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; import org.springframework.boot.actuate.info.InfoContributor; @@ -40,7 +38,7 @@ public class InfoEndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public InfoEndpoint infoEndpoint(ObjectProvider infoContributors) { - return new InfoEndpoint(infoContributors.orderedStream().collect(Collectors.toList())); + return new InfoEndpoint(infoContributors.orderedStream().toList()); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthContributorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthContributorAutoConfiguration.java index b07d4d4e05..9abf74c1af 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthContributorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthContributorAutoConfiguration.java @@ -73,7 +73,7 @@ public class DataSourceHealthContributorAutoConfiguration implements Initializin public DataSourceHealthContributorAutoConfiguration( ObjectProvider metadataProviders) { - this.metadataProviders = metadataProviders.orderedStream().collect(Collectors.toList()); + this.metadataProviders = metadataProviders.orderedStream().toList(); } @Override diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java index fd062849a0..726872e09b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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,6 @@ package org.springframework.boot.actuate.autoconfigure.metrics; -import java.util.List; -import java.util.stream.Collectors; - import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Metrics; import io.micrometer.core.instrument.binder.MeterBinder; @@ -74,7 +71,7 @@ class MeterRegistryConfigurer { @SuppressWarnings("unchecked") private void customize(MeterRegistry registry) { - LambdaSafe.callbacks(MeterRegistryCustomizer.class, asOrderedList(this.customizers), registry) + LambdaSafe.callbacks(MeterRegistryCustomizer.class, this.customizers.orderedStream().toList(), registry) .withLogger(MeterRegistryConfigurer.class).invoke((customizer) -> customizer.customize(registry)); } @@ -86,8 +83,4 @@ class MeterRegistryConfigurer { this.binders.orderedStream().forEach((binder) -> binder.bindTo(registry)); } - private List asOrderedList(ObjectProvider provider) { - return provider.orderedStream().collect(Collectors.toList()); - } - } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java index 88e7d8dece..da6dc9ca14 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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.boot.actuate.autoconfigure.metrics; import java.util.Arrays; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.function.Supplier; -import java.util.stream.Collectors; import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.Meter.Id; @@ -61,11 +61,14 @@ public class PropertiesMeterFilter implements MeterFilter { return new MeterFilter() { }; } - Tags commonTags = Tags.of(tags.entrySet().stream().map((entry) -> Tag.of(entry.getKey(), entry.getValue())) - .collect(Collectors.toList())); + Tags commonTags = Tags.of(tags.entrySet().stream().map(PropertiesMeterFilter::asTag).toList()); return MeterFilter.commonTags(commonTags); } + private static Tag asTag(Entry entry) { + return Tag.of(entry.getKey(), entry.getValue()); + } + @Override public MeterFilterReply accept(Meter.Id id) { boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, true); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/GraphQlMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/GraphQlMetricsAutoConfiguration.java index 93b8d4fbb7..4ee94ebd43 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/GraphQlMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/graphql/GraphQlMetricsAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.metrics.graphql; -import java.util.stream.Collectors; - import graphql.GraphQL; import io.micrometer.core.instrument.MeterRegistry; @@ -56,7 +54,7 @@ public class GraphQlMetricsAutoConfiguration { @Bean @ConditionalOnMissingBean(GraphQlTagsProvider.class) public DefaultGraphQlTagsProvider graphQlTagsProvider(ObjectProvider contributors) { - return new DefaultGraphQlTagsProvider(contributors.orderedStream().collect(Collectors.toList())); + return new DefaultGraphQlTagsProvider(contributors.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.java index 8816f91ce5..a64dc7fcd6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.sql.DataSource; @@ -87,8 +86,7 @@ public class DataSourcePoolMetricsAutoConfiguration { @Override public void bindTo(MeterRegistry registry) { - List metadataProvidersList = this.metadataProviders.stream() - .collect(Collectors.toList()); + List metadataProvidersList = this.metadataProviders.stream().toList(); this.dataSources.forEach((name, dataSource) -> bindDataSourceToRegistry(name, dataSource, metadataProvidersList, registry)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java index 9d0980e23b..ea40aadad0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.metrics.web.reactive; -import java.util.stream.Collectors; - import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.config.MeterFilter; @@ -64,7 +62,7 @@ public class WebFluxMetricsAutoConfiguration { @ConditionalOnMissingBean(WebFluxTagsProvider.class) public DefaultWebFluxTagsProvider webFluxTagsProvider(ObjectProvider contributors) { return new DefaultWebFluxTagsProvider(this.properties.getWeb().getServer().getRequest().isIgnoreTrailingSlash(), - contributors.orderedStream().collect(Collectors.toList())); + contributors.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java index 786e395c5d..70fcfb8b72 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.metrics.web.servlet; -import java.util.stream.Collectors; - import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.config.MeterFilter; import jakarta.servlet.DispatcherType; @@ -76,7 +74,7 @@ public class WebMvcMetricsAutoConfiguration { @ConditionalOnMissingBean(WebMvcTagsProvider.class) public DefaultWebMvcTagsProvider webMvcTagsProvider(ObjectProvider contributors) { return new DefaultWebMvcTagsProvider(this.properties.getWeb().getServer().getRequest().isIgnoreTrailingSlash(), - contributors.orderedStream().collect(Collectors.toList())); + contributors.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/scheduling/ScheduledTasksEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/scheduling/ScheduledTasksEndpointAutoConfiguration.java index c66b532494..45d1168523 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/scheduling/ScheduledTasksEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/scheduling/ScheduledTasksEndpointAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.scheduling; -import java.util.stream.Collectors; - import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint; @@ -40,7 +38,7 @@ public class ScheduledTasksEndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public ScheduledTasksEndpoint scheduledTasksEndpoint(ObjectProvider holders) { - return new ScheduledTasksEndpoint(holders.orderedStream().collect(Collectors.toList())); + return new ScheduledTasksEndpoint(holders.orderedStream().toList()); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java index 8698e00133..b34d8082a0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java @@ -246,8 +246,11 @@ public final class EndpointRequest { } private List getDelegateMatchers(Set paths) { - return paths.stream().map((path) -> new PathPatternParserServerWebExchangeMatcher(path + "/**")) - .collect(Collectors.toList()); + return paths.stream().map(this::getDelegateMatcher).collect(Collectors.toCollection(ArrayList::new)); + } + + private PathPatternParserServerWebExchangeMatcher getDelegateMatcher(String path) { + return new PathPatternParserServerWebExchangeMatcher(path + "/**"); } @Override diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java index 1b9d73701e..e27ecc8c9c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java @@ -270,7 +270,7 @@ public final class EndpointRequest { private List getDelegateMatchers(RequestMatcherFactory requestMatcherFactory, RequestMatcherProvider matcherProvider, Set paths) { return paths.stream().map((path) -> requestMatcherFactory.antPath(matcherProvider, path, "/**")) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ArrayList::new)); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfiguration.java index c5efef0e6c..78541cb9eb 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfiguration.java @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.tracing; import java.util.List; import java.util.regex.Pattern; -import java.util.stream.Collectors; import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.otel.bridge.DefaultHttpClientAttributesGetter; @@ -110,8 +109,7 @@ public class OpenTelemetryAutoConfiguration { @Bean @ConditionalOnMissingBean ContextPropagators otelContextPropagators(ObjectProvider textMapPropagators) { - return ContextPropagators - .create(TextMapPropagator.composite(textMapPropagators.orderedStream().collect(Collectors.toList()))); + return ContextPropagators.create(TextMapPropagator.composite(textMapPropagators.orderedStream().toList())); } @Bean @@ -122,8 +120,11 @@ public class OpenTelemetryAutoConfiguration { @Bean SpanProcessor otelSpanProcessor(ObjectProvider spanExporters) { - return SpanProcessor.composite(spanExporters.orderedStream() - .map((exporter) -> BatchSpanProcessor.builder(exporter).build()).collect(Collectors.toList())); + return SpanProcessor.composite(spanExporters.orderedStream().map(this::buildBatchSpanProcessor).toList()); + } + + private SpanProcessor buildBatchSpanProcessor(SpanExporter exporter) { + return BatchSpanProcessor.builder(exporter).build(); } @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java index 45f8ac96d3..a2aa5c1744 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.web.mappings; -import java.util.stream.Collectors; - import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider; @@ -51,8 +49,7 @@ public class MappingsEndpointAutoConfiguration { @Bean public MappingsEndpoint mappingsEndpoint(ApplicationContext applicationContext, ObjectProvider descriptionProviders) { - return new MappingsEndpoint(descriptionProviders.orderedStream().collect(Collectors.toList()), - applicationContext); + return new MappingsEndpoint(descriptionProviders.orderedStream().toList(), applicationContext); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementWebServerFactoryCustomizer.java index 4b0e3be415..3f3817f6cf 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementWebServerFactoryCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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,11 +16,9 @@ package org.springframework.boot.actuate.autoconfigure.web.server; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.ListableBeanFactory; @@ -77,19 +75,15 @@ public abstract class ManagementWebServerFactoryCustomizer> customizers = Arrays.stream(this.customizerClasses).map(this::getCustomizer) - .filter(Objects::nonNull).collect(Collectors.toList()); - invokeCustomizers(factory, customizers); - } - - private WebServerFactoryCustomizer getCustomizer( - Class> customizerClass) { - try { - return BeanFactoryUtils.beanOfTypeIncludingAncestors(this.beanFactory, customizerClass); - } - catch (NoSuchBeanDefinitionException ex) { - return null; + List> customizers = new ArrayList<>(); + for (Class> customizerClass : this.customizerClasses) { + try { + customizers.add(BeanFactoryUtils.beanOfTypeIncludingAncestors(this.beanFactory, customizerClass)); + } + catch (NoSuchBeanDefinitionException ex) { + } } + invokeCustomizers(factory, customizers); } @SuppressWarnings("unchecked") diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java index fadaeb8fee..a3d7181344 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.net.ssl.SSLException; @@ -211,8 +210,7 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests { .run((context) -> { CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context); Collection endpoints = handlerMapping.getEndpoints(); - List endpointIds = endpoints.stream().map(ExposableWebEndpoint::getEndpointId) - .collect(Collectors.toList()); + List endpointIds = endpoints.stream().map(ExposableWebEndpoint::getEndpointId).toList(); assertThat(endpointIds).contains(EndpointId.of("test")); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java index 38a7042054..6ed5a86179 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -90,8 +89,7 @@ class WebEndpointAutoConfigurationTests { WebEndpointDiscoverer discoverer = context.getBean(WebEndpointDiscoverer.class); Collection endpoints = discoverer.getEndpoints(); ExposableWebEndpoint[] webEndpoints = endpoints.toArray(new ExposableWebEndpoint[0]); - List paths = Arrays.stream(webEndpoints).map(PathMappedEndpoint::getRootPath) - .collect(Collectors.toList()); + List paths = Arrays.stream(webEndpoints).map(PathMappedEndpoint::getRootPath).toList(); assertThat(paths).containsOnly("1/testone", "foo", "testtwo"); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java index 8ab7f40e92..57c1ae0e50 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; import com.fasterxml.jackson.databind.ObjectMapper; @@ -60,8 +59,8 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWit public abstract class AbstractEndpointDocumentationTests { protected static String describeEnumValues(Class> enumType) { - return StringUtils.collectionToDelimitedString(Stream.of(enumType.getEnumConstants()) - .map((constant) -> "`" + constant.name() + "`").collect(Collectors.toList()), ", "); + return StringUtils.collectionToDelimitedString( + Stream.of(enumType.getEnumConstants()).map((constant) -> "`" + constant.name() + "`").toList(), ", "); } protected OperationPreprocessor limit(String... keys) { @@ -112,8 +111,7 @@ public abstract class AbstractEndpointDocumentationTests { @SuppressWarnings("unchecked") private List select(List candidates, Predicate filter) { - return candidates.stream().filter((candidate) -> filter.test((T) candidate)).limit(3) - .collect(Collectors.toList()); + return candidates.stream().filter((candidate) -> filter.test((T) candidate)).limit(3).toList(); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java index bc8258dc5b..f647fbdf0d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.security.servlet; import java.io.IOException; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -152,7 +151,7 @@ class ManagementWebSecurityAutoConfigurationTests { SecurityFilterChain testRemoteDevToolsSecurityFilterChain = context .getBean("testRemoteDevToolsSecurityFilterChain", SecurityFilterChain.class); List orderedSecurityFilterChains = context.getBeanProvider(SecurityFilterChain.class) - .orderedStream().collect(Collectors.toList()); + .orderedStream().toList(); assertThat(orderedSecurityFilterChains).containsExactly(testRemoteDevToolsSecurityFilterChain, testSecurityFilterChain); assertThat(context).doesNotHaveBean(ManagementWebSecurityAutoConfiguration.class); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelectorTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelectorTests.java index 6da00e7953..e95aa81e53 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelectorTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelectorTests.java @@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.web.server; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.jupiter.api.Test; @@ -83,7 +82,7 @@ class ManagementContextConfigurationImportSelectorTests { private final List factoryNames; private TestManagementContextConfigurationsImportSelector(Class... classes) { - this.factoryNames = Stream.of(classes).map(Class::getName).collect(Collectors.toList()); + this.factoryNames = Stream.of(classes).map(Class::getName).toList(); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java index f4c9911c58..0b8851ae5d 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; @@ -110,21 +109,19 @@ public class CachesEndpoint { private List getCacheEntries(Predicate cacheNamePredicate, Predicate cacheManagerNamePredicate) { return this.cacheManagers.keySet().stream().filter(cacheManagerNamePredicate) - .flatMap((cacheManagerName) -> getCacheEntries(cacheManagerName, cacheNamePredicate).stream()) - .collect(Collectors.toList()); + .flatMap((cacheManagerName) -> getCacheEntries(cacheManagerName, cacheNamePredicate).stream()).toList(); } private List getCacheEntries(String cacheManagerName, Predicate cacheNamePredicate) { CacheManager cacheManager = this.cacheManagers.get(cacheManagerName); return cacheManager.getCacheNames().stream().filter(cacheNamePredicate).map(cacheManager::getCache) - .filter(Objects::nonNull).map((cache) -> new CacheEntry(cache, cacheManagerName)) - .collect(Collectors.toList()); + .filter(Objects::nonNull).map((cache) -> new CacheEntry(cache, cacheManagerName)).toList(); } private CacheEntry extractUniqueCacheEntry(String cache, List entries) { if (entries.size() > 1) { throw new NonUniqueCacheException(cache, - entries.stream().map(CacheEntry::getCacheManager).distinct().collect(Collectors.toList())); + entries.stream().map(CacheEntry::getCacheManager).distinct().toList()); } return (!entries.isEmpty() ? entries.get(0) : null); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealth.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealth.java index 005921fd49..486f796096 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealth.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealth.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,6 @@ package org.springframework.boot.actuate.couchbase; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.stream.Collectors; import com.couchbase.client.core.diagnostics.ClusterState; import com.couchbase.client.core.diagnostics.DiagnosticsResult; @@ -44,7 +43,7 @@ class CouchbaseHealth { builder = isCouchbaseUp(this.diagnostics) ? builder.up() : builder.down(); builder.withDetail("sdk", this.diagnostics.sdk()); builder.withDetail("endpoints", this.diagnostics.endpoints().values().stream().flatMap(Collection::stream) - .map(this::describe).collect(Collectors.toList())); + .map(this::describe).toList()); } private boolean isCouchbaseUp(DiagnosticsResult diagnostics) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index a6091f31a9..27c6bdb34f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -100,7 +100,7 @@ public abstract class EndpointDiscoverer, O exten private DiscoveredOperationsFactory getOperationsFactory(ParameterValueMapper parameterValueMapper, Collection invokerAdvisors) { - return new DiscoveredOperationsFactory(parameterValueMapper, invokerAdvisors) { + return new DiscoveredOperationsFactory<>(parameterValueMapper, invokerAdvisors) { @Override protected O createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, @@ -199,8 +199,7 @@ public abstract class EndpointDiscoverer, O exten addOperations(indexed, id, extensionBean.getBean(), true); } assertNoDuplicateOperations(endpointBean, indexed); - List operations = indexed.values().stream().map(this::getLast).filter(Objects::nonNull) - .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); + List operations = indexed.values().stream().map(this::getLast).filter(Objects::nonNull).toList(); return createEndpoint(endpointBean.getBean(), id, endpointBean.isEnabledByDefault(), operations); } @@ -224,7 +223,7 @@ public abstract class EndpointDiscoverer, O exten private void assertNoDuplicateOperations(EndpointBean endpointBean, MultiValueMap indexed) { List duplicates = indexed.entrySet().stream().filter((entry) -> entry.getValue().size() > 1) - .map(Map.Entry::getKey).collect(Collectors.toList()); + .map(Map.Entry::getKey).toList(); if (!duplicates.isEmpty()) { Set extensions = endpointBean.getExtensions(); String extensionBeanNames = extensions.stream().map(ExtensionBean::getBeanName) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporter.java index 9cb1f550e0..8a3445f174 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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.boot.actuate.endpoint.jmx; import java.util.Collection; import java.util.Collections; -import java.util.stream.Collectors; import javax.management.InstanceNotFoundException; import javax.management.MBeanRegistrationException; @@ -87,7 +86,7 @@ public class JmxEndpointExporter implements InitializingBean, DisposableBean, Be } private Collection register() { - return this.endpoints.stream().map(this::register).collect(Collectors.toList()); + return this.endpoints.stream().map(this::register).toList(); } private ObjectName register(ExposableJmxEndpoint endpoint) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/DiscoveredJmxOperation.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/DiscoveredJmxOperation.java index 60750d1cd4..32e948fb01 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/DiscoveredJmxOperation.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/DiscoveredJmxOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.function.Supplier; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.boot.actuate.endpoint.EndpointId; @@ -84,7 +83,9 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO Method method = operationMethod.getMethod(); ManagedOperationParameter[] managed = jmxAttributeSource.getManagedOperationParameters(method); if (managed.length == 0) { - return asList(operationMethod.getParameters().stream().map(DiscoveredJmxOperationParameter::new)); + Stream parameters = operationMethod.getParameters().stream() + .map(DiscoveredJmxOperationParameter::new); + return parameters.toList(); } return mergeParameters(operationMethod.getParameters(), managed); } @@ -98,10 +99,6 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO return Collections.unmodifiableList(merged); } - private List asList(Stream stream) { - return stream.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); - } - @Override public String getName() { return this.name; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java index 26e8a10476..d9a0ee5190 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java @@ -20,9 +20,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.boot.actuate.endpoint.EndpointId; @@ -107,7 +105,7 @@ public class PathMappedEndpoints implements Iterable { * @return all root paths */ public Collection getAllRootPaths() { - return asList(stream().map(PathMappedEndpoint::getRootPath)); + return stream().map(PathMappedEndpoint::getRootPath).toList(); } /** @@ -115,7 +113,7 @@ public class PathMappedEndpoints implements Iterable { * @return all root paths */ public Collection getAllPaths() { - return asList(stream().map(this::getPath)); + return stream().map(this::getPath).toList(); } /** @@ -145,8 +143,4 @@ public class PathMappedEndpoints implements Iterable { return (endpoint != null) ? this.basePath + "/" + endpoint.getRootPath() : null; } - private List asList(Stream stream) { - return stream.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); - } - } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java index eb15dbe81e..ec9f8671a5 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java @@ -21,7 +21,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.flywaydb.core.Flyway; @@ -117,7 +116,7 @@ public class FlywayEndpoint { private final List migrations; private FlywayDescriptor(MigrationInfo[] migrations) { - this.migrations = Stream.of(migrations).map(FlywayMigration::new).collect(Collectors.toList()); + this.migrations = Stream.of(migrations).map(FlywayMigration::new).toList(); } public FlywayDescriptor(List migrations) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java index 4c5b9efe79..6cb9295f64 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.util.CollectionUtils; @@ -81,7 +80,7 @@ public class SimpleStatusAggregator implements StatusAggregator { } private static List getUniformCodes(Stream codes) { - return codes.map(SimpleStatusAggregator::getUniformCode).collect(Collectors.toList()); + return codes.map(SimpleStatusAggregator::getUniformCode).toList(); } private static String getUniformCode(String code) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java index da4222bb86..a5dfa76d97 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; import javax.sql.DataSource; @@ -87,8 +86,7 @@ public class LiquibaseEndpoint { database.setDatabaseChangeLogLockTableName(liquibase.getDatabaseChangeLogLockTable()); StandardChangeLogHistoryService service = new StandardChangeLogHistoryService(); service.setDatabase(database); - return new LiquibaseBean( - service.getRanChangeSets().stream().map(ChangeSet::new).collect(Collectors.toList())); + return new LiquibaseBean(service.getRanChangeSets().stream().map(ChangeSet::new).toList()); } finally { if (database != null) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/PlainTextThreadDumpFormatter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/PlainTextThreadDumpFormatter.java index 80569a7967..0893bb6985 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/PlainTextThreadDumpFormatter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/PlainTextThreadDumpFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -26,7 +26,6 @@ import java.lang.management.ThreadInfo; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -73,8 +72,7 @@ class PlainTextThreadDumpFormatter { } private List lockedMonitorsForDepth(MonitorInfo[] lockedMonitors, int depth) { - return Stream.of(lockedMonitors).filter((lockedMonitor) -> lockedMonitor.getLockedStackDepth() == depth) - .collect(Collectors.toList()); + return Stream.of(lockedMonitors).filter((candidate) -> candidate.getLockedStackDepth() == depth).toList(); } private void writeStackTraceElement(PrintWriter writer, StackTraceElement element, ThreadInfo info, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java index 549d961e57..256ccb69c9 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java @@ -26,7 +26,6 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.function.BiFunction; -import java.util.stream.Collectors; import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.MeterRegistry; @@ -92,10 +91,7 @@ public class MetricsEndpoint { } private List parseTags(List tags) { - if (tags == null) { - return Collections.emptyList(); - } - return tags.stream().map(this::parseTag).collect(Collectors.toList()); + return (tags != null) ? tags.stream().map(this::parseTag).toList() : Collections.emptyList(); } private Tag parseTag(String tag) { @@ -157,8 +153,7 @@ public class MetricsEndpoint { } private List asList(Map map, BiFunction mapper) { - return map.entrySet().stream().map((entry) -> mapper.apply(entry.getKey(), entry.getValue())) - .collect(Collectors.toList()); + return map.entrySet().stream().map((entry) -> mapper.apply(entry.getKey(), entry.getValue())).toList(); } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/quartz/QuartzEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/quartz/QuartzEndpoint.java index f802bcaeaf..8e138ed0c5 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/quartz/QuartzEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/quartz/QuartzEndpoint.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; -import java.util.stream.Collectors; import org.quartz.CalendarIntervalTrigger; import org.quartz.CronTrigger; @@ -99,7 +98,7 @@ public class QuartzEndpoint { Map result = new LinkedHashMap<>(); for (String groupName : this.scheduler.getJobGroupNames()) { List jobs = this.scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName)).stream() - .map((key) -> key.getName()).collect(Collectors.toList()); + .map((key) -> key.getName()).toList(); result.put(groupName, Collections.singletonMap("jobs", jobs)); } return new QuartzGroups(result); @@ -117,7 +116,7 @@ public class QuartzEndpoint { Map groupDetails = new LinkedHashMap<>(); groupDetails.put("paused", pausedTriggerGroups.contains(groupName)); groupDetails.put("triggers", this.scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(groupName)) - .stream().map((key) -> key.getName()).collect(Collectors.toList())); + .stream().map((key) -> key.getName()).toList()); result.put(groupName, groupDetails); } return new QuartzGroups(result); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/session/SessionsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/session/SessionsEndpoint.java index d6ae25cb23..99598964b0 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/session/SessionsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/session/SessionsEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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,7 +20,6 @@ import java.time.Instant; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; @@ -77,7 +76,7 @@ public class SessionsEndpoint { private final List sessions; public SessionsReport(Map sessions) { - this.sessions = sessions.values().stream().map(SessionDescriptor::new).collect(Collectors.toList()); + this.sessions = sessions.values().stream().map(SessionDescriptor::new).toList(); } public List getSessions() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/DispatcherHandlersMappingDescriptionProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/DispatcherHandlersMappingDescriptionProvider.java index b59bceabc1..9a691929bb 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/DispatcherHandlersMappingDescriptionProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/DispatcherHandlersMappingDescriptionProvider.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import reactor.core.publisher.Mono; @@ -79,7 +78,7 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc } private List describeMappings(DispatcherHandler dispatcherHandler) { - return dispatcherHandler.getHandlerMappings().stream().flatMap(this::describe).collect(Collectors.toList()); + return dispatcherHandler.getHandlerMappings().stream().flatMap(this::describe).toList(); } @SuppressWarnings("unchecked") @@ -111,7 +110,7 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc @Override public List describe(RequestMappingInfoHandlerMapping handlerMapping) { Map handlerMethods = handlerMapping.getHandlerMethods(); - return handlerMethods.entrySet().stream().map(this::describe).collect(Collectors.toList()); + return handlerMethods.entrySet().stream().map(this::describe).toList(); } private DispatcherHandlerMappingDescription describe(Entry mapping) { @@ -134,7 +133,7 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc @Override public List describe(AbstractUrlHandlerMapping handlerMapping) { - return handlerMapping.getHandlerMap().entrySet().stream().map(this::describe).collect(Collectors.toList()); + return handlerMapping.getHandlerMap().entrySet().stream().map(this::describe).toList(); } private DispatcherHandlerMappingDescription describe(Entry mapping) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/RequestMappingConditionsDescription.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/RequestMappingConditionsDescription.java index a133bb5310..2e2baa5fd2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/RequestMappingConditionsDescription.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/RequestMappingConditionsDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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,6 +16,7 @@ package org.springframework.boot.actuate.web.mappings.reactive; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -48,16 +49,16 @@ public class RequestMappingConditionsDescription { RequestMappingConditionsDescription(RequestMappingInfo requestMapping) { this.consumes = requestMapping.getConsumesCondition().getExpressions().stream() - .map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); + .map(MediaTypeExpressionDescription::new).toList(); this.headers = requestMapping.getHeadersCondition().getExpressions().stream() - .map(NameValueExpressionDescription::new).collect(Collectors.toList()); + .map(NameValueExpressionDescription::new).toList(); this.methods = requestMapping.getMethodsCondition().getMethods(); this.params = requestMapping.getParamsCondition().getExpressions().stream() - .map(NameValueExpressionDescription::new).collect(Collectors.toList()); + .map(NameValueExpressionDescription::new).toList(); this.patterns = requestMapping.getPatternsCondition().getPatterns().stream().map(PathPattern::getPatternString) - .collect(Collectors.toSet()); + .collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet)); this.produces = requestMapping.getProducesCondition().getExpressions().stream() - .map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); + .map(MediaTypeExpressionDescription::new).toList(); } public List getConsumes() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletsMappingDescriptionProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletsMappingDescriptionProvider.java index 262457a54d..8415d39e69 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletsMappingDescriptionProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletsMappingDescriptionProvider.java @@ -23,7 +23,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.stream.Collectors; import java.util.stream.Stream; import jakarta.servlet.Servlet; @@ -104,7 +103,7 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc } private List describeMappings(DispatcherServletHandlerMappings mappings) { - return mappings.getHandlerMappings().stream().flatMap(this::describe).collect(Collectors.toList()); + return mappings.getHandlerMappings().stream().flatMap(this::describe).toList(); } private Stream describe(T handlerMapping) { @@ -141,7 +140,7 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc @Override public List describe(RequestMappingInfoHandlerMapping handlerMapping) { Map handlerMethods = handlerMapping.getHandlerMethods(); - return handlerMethods.entrySet().stream().map(this::describe).collect(Collectors.toList()); + return handlerMethods.entrySet().stream().map(this::describe).toList(); } private DispatcherServletMappingDescription describe(Entry mapping) { @@ -164,7 +163,7 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc @Override public List describe(AbstractUrlHandlerMapping handlerMapping) { - return handlerMapping.getHandlerMap().entrySet().stream().map(this::describe).collect(Collectors.toList()); + return handlerMapping.getHandlerMap().entrySet().stream().map(this::describe).toList(); } private DispatcherServletMappingDescription describe(Entry mapping) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/FiltersMappingDescriptionProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/FiltersMappingDescriptionProvider.java index a443a0a236..1a80baaa1a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/FiltersMappingDescriptionProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/FiltersMappingDescriptionProvider.java @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.web.mappings.servlet; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import jakarta.servlet.Filter; import jakarta.servlet.ServletContext; @@ -46,7 +45,7 @@ public class FiltersMappingDescriptionProvider implements MappingDescriptionProv public List describeMappings(ApplicationContext context) { if (context instanceof WebApplicationContext webApplicationContext) { return webApplicationContext.getServletContext().getFilterRegistrations().values().stream() - .map(FilterRegistrationMappingDescription::new).collect(Collectors.toList()); + .map(FilterRegistrationMappingDescription::new).toList(); } return Collections.emptyList(); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java index 46cafd0474..93a9526506 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/RequestMappingConditionsDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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.boot.actuate.web.mappings.servlet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.mvc.condition.MediaTypeExpression; @@ -48,15 +47,15 @@ public class RequestMappingConditionsDescription { RequestMappingConditionsDescription(RequestMappingInfo requestMapping) { this.consumes = requestMapping.getConsumesCondition().getExpressions().stream() - .map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); + .map(MediaTypeExpressionDescription::new).toList(); this.headers = requestMapping.getHeadersCondition().getExpressions().stream() - .map(NameValueExpressionDescription::new).collect(Collectors.toList()); + .map(NameValueExpressionDescription::new).toList(); this.methods = requestMapping.getMethodsCondition().getMethods(); this.params = requestMapping.getParamsCondition().getExpressions().stream() - .map(NameValueExpressionDescription::new).collect(Collectors.toList()); + .map(NameValueExpressionDescription::new).toList(); this.patterns = extractPathPatterns(requestMapping); this.produces = requestMapping.getProducesCondition().getExpressions().stream() - .map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); + .map(MediaTypeExpressionDescription::new).toList(); } private Set extractPathPatterns(RequestMappingInfo requestMapping) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/ServletsMappingDescriptionProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/ServletsMappingDescriptionProvider.java index 060d6dc993..47ebfe9946 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/ServletsMappingDescriptionProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/ServletsMappingDescriptionProvider.java @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.web.mappings.servlet; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import jakarta.servlet.Servlet; import jakarta.servlet.ServletContext; @@ -46,7 +45,7 @@ public class ServletsMappingDescriptionProvider implements MappingDescriptionPro public List describeMappings(ApplicationContext context) { if (context instanceof WebApplicationContext webApplicationContext) { return webApplicationContext.getServletContext().getServletRegistrations().values().stream() - .map(ServletRegistrationMappingDescription::new).collect(Collectors.toList()); + .map(ServletRegistrationMappingDescription::new).toList(); } return Collections.emptyList(); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/beans/BeansEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/beans/BeansEndpointTests.java index 0bb7d07d1b..b4a80437cf 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/beans/BeansEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/beans/BeansEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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.boot.actuate.beans; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.jupiter.api.Test; @@ -67,7 +66,7 @@ class BeansEndpointTests { .getAutowireCapableBeanFactory(); List infrastructureBeans = Stream.of(context.getBeanDefinitionNames()) .filter((name) -> BeanDefinition.ROLE_INFRASTRUCTURE == factory.getBeanDefinition(name).getRole()) - .collect(Collectors.toList()); + .toList(); ApplicationBeans result = context.getBean(BeansEndpoint.class).beans(); ContextBeans contextDescriptor = result.getContexts().get(context.getId()); Map beans = contextDescriptor.getBeans(); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParametersTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParametersTests.java index f18c92b8ee..2a0fc98413 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParametersTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParametersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.util.Iterator; import java.util.List; import java.util.Spliterator; import java.util.Spliterators; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -107,7 +106,7 @@ class OperationMethodParametersTests { } private void assertParameters(Stream stream) { - List parameters = stream.collect(Collectors.toList()); + List parameters = stream.toList(); assertThat(parameters).hasSize(1); OperationParameter parameter = parameters.get(0); assertThat(parameter.getName()).isEqualTo("name"); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscovererTests.java index 4ca1a8eae8..88127143dc 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscovererTests.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -118,8 +117,7 @@ class ControllerEndpointDiscovererTests { this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class) .run(assertDiscoverer((discoverer) -> { Collection endpoints = discoverer.getEndpoints(); - List ids = endpoints.stream().map(ExposableControllerEndpoint::getEndpointId) - .collect(Collectors.toList()); + List ids = endpoints.stream().map(ExposableControllerEndpoint::getEndpointId).toList(); assertThat(ids).containsOnly(EndpointId.of("testcontroller"), EndpointId.of("testrestcontroller")); })); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscovererTests.java index d5ca292891..d5fd60c890 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscovererTests.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.List; import java.util.function.Consumer; import java.util.function.Supplier; -import java.util.stream.Collectors; import jakarta.servlet.GenericServlet; import jakarta.servlet.ServletException; @@ -100,8 +99,7 @@ class ServletEndpointDiscovererTests { this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class) .run(assertDiscoverer((discoverer) -> { Collection endpoints = discoverer.getEndpoints(); - List ids = endpoints.stream().map(ExposableServletEndpoint::getEndpointId) - .collect(Collectors.toList()); + List ids = endpoints.stream().map(ExposableServletEndpoint::getEndpointId).toList(); assertThat(ids).containsOnly(EndpointId.of("testservlet")); })); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java index 526eee134a..18048ed371 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.assertj.core.api.Condition; @@ -255,7 +254,7 @@ class WebEndpointDiscovererTests { } private List requestPredicates(ExposableWebEndpoint endpoint) { - return endpoint.getOperations().stream().map(WebOperation::getRequestPredicate).collect(Collectors.toList()); + return endpoint.getOperations().stream().map(WebOperation::getRequestPredicate).toList(); } private Condition> requestPredicates( diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java index b0505c4ee5..2066e8a742 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java @@ -103,12 +103,12 @@ class DefaultWebMvcTagsProviderTests { @Override public Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, Throwable exception) { - return this.tagNames.stream().map((name) -> Tag.of(name, "value")).collect(Collectors.toList()); + return this.tagNames.stream().map((name) -> Tag.of(name, "value")).toList(); } @Override public Iterable getLongRequestTags(HttpServletRequest request, Object handler) { - return this.tagNames.stream().map((name) -> Tag.of(name, "value")).collect(Collectors.toList()); + return this.tagNames.stream().map((name) -> Tag.of(name, "value")).toList(); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointTestInvocationContextProvider.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointTestInvocationContextProvider.java index 1bb08174fb..a4cab4516b 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointTestInvocationContextProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointTestInvocationContextProvider.java @@ -17,6 +17,7 @@ package org.springframework.boot.actuate.endpoint.web.test; import java.time.Duration; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -144,7 +145,7 @@ class WebEndpointTestInvocationContextProvider implements TestTemplateInvocation public void beforeEach(ExtensionContext extensionContext) throws Exception { List> configurationClasses = Stream .of(extensionContext.getRequiredTestClass().getDeclaredClasses()).filter(this::isConfiguration) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ArrayList::new)); this.context = this.contextFactory.apply(configurationClasses); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/info/InfoEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/info/InfoEndpointWebIntegrationTests.java index d05a98dc6d..f3d83dbd93 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/info/InfoEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/info/InfoEndpointWebIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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.boot.actuate.info; import java.util.LinkedHashMap; import java.util.Map; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest; @@ -51,7 +50,7 @@ class InfoEndpointWebIntegrationTests { @Bean InfoEndpoint endpoint(ObjectProvider infoContributors) { - return new InfoEndpoint(infoContributors.orderedStream().collect(Collectors.toList())); + return new InfoEndpoint(infoContributors.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProviderTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProviderTests.java index ae2138346c..c1541223ea 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProviderTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -71,7 +71,7 @@ class DefaultWebFluxTagsProviderTests { @Override public Iterable httpRequestTags(ServerWebExchange exchange, Throwable ex) { - return this.tagNames.stream().map((name) -> Tag.of(name, "value")).collect(Collectors.toList()); + return this.tagNames.stream().map((name) -> Tag.of(name, "value")).toList(); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java index dc9bfa03db..d9ca022512 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java @@ -446,8 +446,7 @@ public class AutoConfigurationImportSelector implements DeferredImportSelector, processedConfigurations.removeAll(allExclusions); return sortAutoConfigurations(processedConfigurations, getAutoConfigurationMetadata()).stream() - .map((importClassName) -> new Entry(this.entries.get(importClassName), importClassName)) - .collect(Collectors.toList()); + .map((importClassName) -> new Entry(this.entries.get(importClassName), importClassName)).toList(); } private AutoConfigurationMetadata getAutoConfigurationMetadata() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java index 904d1eb1ee..f2c584683f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -47,7 +47,7 @@ public class AutoConfigurations extends Configurations implements Ordered { @Override protected Collection> sort(Collection> classes) { - List names = classes.stream().map(Class::getName).collect(Collectors.toList()); + List names = classes.stream().map(Class::getName).toList(); List sorted = SORTER.getInPriorityOrder(names); return sorted.stream().map((className) -> ClassUtils.resolveClassName(className, null)) .collect(Collectors.toCollection(ArrayList::new)); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java index 3a2a6bceb7..ba01ac6bc5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,6 @@ package org.springframework.boot.autoconfigure.amqp; -import java.util.stream.Collectors; - import org.springframework.amqp.rabbit.annotation.EnableRabbit; import org.springframework.amqp.rabbit.config.ContainerCustomizer; import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory; @@ -69,8 +67,7 @@ class RabbitAnnotationDrivenConfiguration { this.properties); configurer.setMessageConverter(this.messageConverter.getIfUnique()); configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique()); - configurer.setRetryTemplateCustomizers( - this.retryTemplateCustomizers.orderedStream().collect(Collectors.toList())); + configurer.setRetryTemplateCustomizers(this.retryTemplateCustomizers.orderedStream().toList()); return configurer; } @@ -94,8 +91,7 @@ class RabbitAnnotationDrivenConfiguration { this.properties); configurer.setMessageConverter(this.messageConverter.getIfUnique()); configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique()); - configurer.setRetryTemplateCustomizers( - this.retryTemplateCustomizers.orderedStream().collect(Collectors.toList())); + configurer.setRetryTemplateCustomizers(this.retryTemplateCustomizers.orderedStream().toList()); return configurer; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index eef1a834db..12a621faed 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.amqp; -import java.util.stream.Collectors; - import com.rabbitmq.client.Channel; import com.rabbitmq.client.impl.CredentialsProvider; import com.rabbitmq.client.impl.CredentialsRefreshService; @@ -149,8 +147,7 @@ public class RabbitAutoConfiguration { ObjectProvider retryTemplateCustomizers) { RabbitTemplateConfigurer configurer = new RabbitTemplateConfigurer(properties); configurer.setMessageConverter(messageConverter.getIfUnique()); - configurer - .setRetryTemplateCustomizers(retryTemplateCustomizers.orderedStream().collect(Collectors.toList())); + configurer.setRetryTemplateCustomizers(retryTemplateCustomizers.orderedStream().toList()); return configurer; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java index 5804dec8de..74674718bf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.cache; -import java.util.stream.Collectors; - import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -67,7 +65,7 @@ public class CacheAutoConfiguration { @Bean @ConditionalOnMissingBean public CacheManagerCustomizers cacheManagerCustomizers(ObjectProvider> customizers) { - return new CacheManagerCustomizers(customizers.orderedStream().collect(Collectors.toList())); + return new CacheManagerCustomizers(customizers.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index 15f6153294..377f50139b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java @@ -24,7 +24,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Supplier; -import java.util.stream.Collectors; import javax.net.ssl.SSLContext; @@ -222,8 +221,7 @@ public class CassandraAutoConfiguration { private List mapContactPoints(CassandraProperties properties) { if (properties.getContactPoints() != null) { return properties.getContactPoints().stream() - .map((candidate) -> formatContactPoint(candidate, properties.getPort())) - .collect(Collectors.toList()); + .map((candidate) -> formatContactPoint(candidate, properties.getPort())).toList(); } return null; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java index aa708df0dd..fe9773a417 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java @@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.condition; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style; import org.springframework.context.annotation.Condition; @@ -51,7 +50,7 @@ class OnPropertyCondition extends SpringBootCondition { List allAnnotationAttributes = metadata.getAnnotations() .stream(ConditionalOnProperty.class.getName()) .filter(MergedAnnotationPredicates.unique(MergedAnnotation::getMetaTypes)) - .map(MergedAnnotation::asAnnotationAttributes).collect(Collectors.toList()); + .map(MergedAnnotation::asAnnotationAttributes).toList(); List noMatch = new ArrayList<>(); List match = new ArrayList<>(); for (AnnotationAttributes annotationAttributes : allAnnotationAttributes) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java index 50264211cb..07249d917a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java @@ -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.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryUtils; @@ -137,7 +136,7 @@ class NoSuchBeanDefinitionFailureAnalyzer extends AbstractInjectionFailureAnalyz return Arrays.stream(beanNames) .map((beanName) -> new UserConfigurationResult(getFactoryMethodMetadata(beanName), this.beanFactory.getBean(beanName).equals(null))) - .collect(Collectors.toList()); + .toList(); } private MethodMetadata getFactoryMethodMetadata(String beanName) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 3e8edddd8f..76e070e4f3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -24,7 +24,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; import javax.sql.DataSource; @@ -117,10 +116,8 @@ public class FlywayAutoConfiguration { FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader()); configureDataSource(configuration, properties, flywayDataSource.getIfAvailable(), dataSource.getIfUnique()); configureProperties(configuration, properties); - List orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList()); - configureCallbacks(configuration, orderedCallbacks); - List migrations = javaMigrations.stream().collect(Collectors.toList()); - configureJavaMigrations(configuration, migrations); + configureCallbacks(configuration, callbacks.orderedStream().toList()); + configureJavaMigrations(configuration, javaMigrations.orderedStream().toList()); fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration)); return configuration.load(); } @@ -282,8 +279,7 @@ public class FlywayAutoConfiguration { return locations; } String vendor = databaseDriver.getId(); - return locations.stream().map((location) -> location.replace(VENDOR_PLACEHOLDER, vendor)) - .collect(Collectors.toList()); + return locations.stream().map((location) -> location.replace(VENDOR_PLACEHOLDER, vendor)).toList(); } private DatabaseDriver getDatabaseDriver() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java index bc90f07e5c..1850e0c364 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import graphql.GraphQL; import graphql.execution.instrumentation.Instrumentation; @@ -84,9 +83,9 @@ public class GraphQlAutoConfiguration { Resource[] schemaResources = resolveSchemaResources(resourcePatternResolver, schemaLocations, properties.getSchema().getFileExtensions()); GraphQlSource.SchemaResourceBuilder builder = GraphQlSource.schemaResourceBuilder() - .schemaResources(schemaResources).exceptionResolvers(toList(exceptionResolvers)) - .subscriptionExceptionResolvers(toList(subscriptionExceptionResolvers)) - .instrumentation(toList(instrumentations)); + .schemaResources(schemaResources).exceptionResolvers(exceptionResolvers.orderedStream().toList()) + .subscriptionExceptionResolvers(subscriptionExceptionResolvers.orderedStream().toList()) + .instrumentation(instrumentations.orderedStream().toList()); if (!properties.getSchema().getIntrospection().isEnabled()) { builder.configureRuntimeWiring(this::enableIntrospection); } @@ -144,8 +143,4 @@ public class GraphQlAutoConfiguration { return controllerConfigurer; } - private List toList(ObjectProvider provider) { - return provider.orderedStream().collect(Collectors.toList()); - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslSourceBuilderCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslSourceBuilderCustomizer.java index 080d57a7e7..ae0db51b20 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslSourceBuilderCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslSourceBuilderCustomizer.java @@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.graphql.data; import java.util.Collections; import java.util.List; import java.util.function.BiFunction; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer; @@ -47,15 +46,13 @@ class GraphQlQuerydslSourceBuilderCustomizer implements GraphQlSourceBuild GraphQlQuerydslSourceBuilderCustomizer( BiFunction, List, RuntimeWiringConfigurer> wiringConfigurerFactory, ObjectProvider executors, ObjectProvider reactiveExecutors) { - this(wiringConfigurerFactory, toList(executors), toList(reactiveExecutors)); + this.wiringConfigurerFactory = wiringConfigurerFactory; + this.executors = asList(executors); + this.reactiveExecutors = asList(reactiveExecutors); } - GraphQlQuerydslSourceBuilderCustomizer( - BiFunction, List, RuntimeWiringConfigurer> wiringConfigurerFactory, List executors, - List reactiveExecutors) { - this.wiringConfigurerFactory = wiringConfigurerFactory; - this.executors = executors; - this.reactiveExecutors = reactiveExecutors; + private static List asList(ObjectProvider provider) { + return (provider != null) ? provider.orderedStream().toList() : Collections.emptyList(); } @Override @@ -65,8 +62,4 @@ class GraphQlQuerydslSourceBuilderCustomizer implements GraphQlSourceBuild } } - private static List toList(ObjectProvider provider) { - return (provider != null) ? provider.orderedStream().collect(Collectors.toList()) : Collections.emptyList(); - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java index 70178c8016..252609b2dc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfiguration.java @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.graphql.reactive; import java.util.Collections; -import java.util.stream.Collectors; import graphql.GraphQL; import org.apache.commons.logging.Log; @@ -96,9 +95,8 @@ public class GraphQlWebFluxAutoConfiguration { @Bean @ConditionalOnMissingBean public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, - ObjectProvider interceptorsProvider) { - return WebGraphQlHandler.builder(service) - .interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList())).build(); + ObjectProvider interceptors) { + return WebGraphQlHandler.builder(service).interceptors(interceptors.orderedStream().toList()).build(); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfiguration.java index fc44994770..66f202fc23 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfiguration.java @@ -16,9 +16,6 @@ package org.springframework.boot.autoconfigure.graphql.rsocket; -import java.util.List; -import java.util.stream.Collectors; - import com.fasterxml.jackson.databind.ObjectMapper; import graphql.GraphQL; import io.rsocket.core.RSocketServer; @@ -58,10 +55,9 @@ public class GraphQlRSocketAutoConfiguration { @Bean @ConditionalOnMissingBean public GraphQlRSocketHandler graphQlRSocketHandler(ExecutionGraphQlService graphQlService, - ObjectProvider interceptorsProvider, ObjectMapper objectMapper) { - List interceptors = interceptorsProvider.orderedStream() - .collect(Collectors.toList()); - return new GraphQlRSocketHandler(graphQlService, interceptors, new Jackson2JsonEncoder(objectMapper)); + ObjectProvider interceptors, ObjectMapper objectMapper) { + return new GraphQlRSocketHandler(graphQlService, interceptors.orderedStream().toList(), + new Jackson2JsonEncoder(objectMapper)); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java index 811fc06754..11cdedb503 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.graphql.servlet; import java.util.Collections; import java.util.Map; -import java.util.stream.Collectors; import graphql.GraphQL; import jakarta.websocket.server.ServerContainer; @@ -97,9 +96,8 @@ public class GraphQlWebMvcAutoConfiguration { @Bean @ConditionalOnMissingBean public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, - ObjectProvider interceptorsProvider) { - return WebGraphQlHandler.builder(service) - .interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList())).build(); + ObjectProvider interceptors) { + return WebGraphQlHandler.builder(service).interceptors(interceptors.orderedStream().toList()).build(); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java index 977788ee89..22720348a2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java @@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.h2; import java.sql.Connection; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import javax.sql.DataSource; @@ -39,6 +38,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; +import org.springframework.core.log.LogMessage; /** * {@link EnableAutoConfiguration Auto-configuration} for H2's web console. @@ -83,20 +83,19 @@ public class H2ConsoleAutoConfiguration { } private void logDataSources(ObjectProvider dataSource, String path) { - List urls = dataSource.orderedStream().map((available) -> { - try (Connection connection = available.getConnection()) { - return "'" + connection.getMetaData().getURL() + "'"; - } - catch (Exception ex) { - return null; - } - }).filter(Objects::nonNull).collect(Collectors.toList()); + List urls = dataSource.orderedStream().map(this::getConnectionUrl).filter(Objects::nonNull).toList(); if (!urls.isEmpty()) { - StringBuilder sb = new StringBuilder("H2 console available at '").append(path).append("'. "); - String tmp = (urls.size() > 1) ? "Databases" : "Database"; - sb.append(tmp).append(" available at "); - sb.append(String.join(", ", urls)); - logger.info(sb.toString()); + logger.info(LogMessage.format("H2 console available at '%s'. %s available at %s", path, + (urls.size() > 1) ? "Databases" : "Database", String.join(", ", urls))); + } + } + + private String getConnectionUrl(DataSource dataSource) { + try (Connection connection = dataSource.getConnection()) { + return "'" + connection.getMetaData().getURL() + "'"; + } + catch (Exception ex) { + return null; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java index a8905c5a1d..fb345ce95b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.http; -import java.util.stream.Collectors; - import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.beans.factory.ObjectProvider; @@ -73,7 +71,7 @@ public class HttpMessageConvertersAutoConfiguration { @Bean @ConditionalOnMissingBean public HttpMessageConverters messageConverters(ObjectProvider> converters) { - return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList())); + return new HttpMessageConverters(converters.orderedStream().toList()); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java index 1c1841a55a..49f1b19a5d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java @@ -16,9 +16,6 @@ package org.springframework.boot.autoconfigure.jms.artemis; -import java.util.List; -import java.util.stream.Collectors; - import org.apache.activemq.artemis.api.core.QueueConfiguration; import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.core.config.CoreAddressConfiguration; @@ -90,19 +87,13 @@ class ArtemisEmbeddedServerConfiguration { JMSConfiguration artemisJmsConfiguration(ObjectProvider queuesConfiguration, ObjectProvider topicsConfiguration) { JMSConfiguration configuration = new JMSConfigurationImpl(); - addAll(configuration.getQueueConfigurations(), queuesConfiguration); - addAll(configuration.getTopicConfigurations(), topicsConfiguration); + configuration.getQueueConfigurations().addAll(queuesConfiguration.orderedStream().toList()); + configuration.getTopicConfigurations().addAll(topicsConfiguration.orderedStream().toList()); addQueues(configuration, this.properties.getEmbedded().getQueues()); addTopics(configuration, this.properties.getEmbedded().getTopics()); return configuration; } - private void addAll(List list, ObjectProvider items) { - if (items != null) { - list.addAll(items.orderedStream().collect(Collectors.toList())); - } - } - private void addQueues(JMSConfiguration configuration, String[] queues) { boolean persistent = this.properties.getEmbedded().isPersistent(); for (String queue : queues) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportMessage.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportMessage.java index efe02b06ab..6bd99fe766 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportMessage.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportMessage.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.stream.Collectors; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcome; @@ -72,7 +71,7 @@ public class ConditionEvaluationReportMessage { message.append(String.format("Positive matches:%n")); message.append(String.format("-----------------%n")); List> matched = shortOutcomes.entrySet().stream() - .filter((entry) -> entry.getValue().isFullMatch()).collect(Collectors.toList()); + .filter((entry) -> entry.getValue().isFullMatch()).toList(); if (matched.isEmpty()) { message.append(String.format("%n None%n")); } @@ -86,7 +85,7 @@ public class ConditionEvaluationReportMessage { message.append(String.format("Negative matches:%n")); message.append(String.format("-----------------%n")); List> nonMatched = shortOutcomes.entrySet().stream() - .filter((entry) -> !entry.getValue().isFullMatch()).collect(Collectors.toList()); + .filter((entry) -> !entry.getValue().isFullMatch()).toList(); if (nonMatched.isEmpty()) { message.append(String.format("%n None%n")); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java index 4eb57d42b9..9eb3929181 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.mongo; -import java.util.stream.Collectors; - import com.mongodb.MongoClientSettings; import com.mongodb.client.MongoClient; @@ -51,8 +49,7 @@ public class MongoAutoConfiguration { @ConditionalOnMissingBean(MongoClient.class) public MongoClient mongo(ObjectProvider builderCustomizers, MongoClientSettings settings) { - return new MongoClientFactory(builderCustomizers.orderedStream().collect(Collectors.toList())) - .createMongoClient(settings); + return new MongoClientFactory(builderCustomizers.orderedStream().toList()).createMongoClient(settings); } @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.java index d22d0c3a04..2b4761bcca 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.mongo; -import java.util.stream.Collectors; - import com.mongodb.MongoClientSettings; import com.mongodb.MongoClientSettings.Builder; import com.mongodb.connection.netty.NettyStreamFactoryFactory; @@ -57,7 +55,7 @@ public class MongoReactiveAutoConfiguration { public MongoClient reactiveStreamsMongoClient( ObjectProvider builderCustomizers, MongoClientSettings settings) { ReactiveMongoClientFactory factory = new ReactiveMongoClientFactory( - builderCustomizers.orderedStream().collect(Collectors.toList())); + builderCustomizers.orderedStream().toList()); return factory.createMongoClient(settings); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.java index bfc06a8bbb..272987b6c3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.java @@ -22,7 +22,6 @@ import java.time.Duration; import java.util.List; import java.util.Locale; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import org.neo4j.driver.AuthToken; import org.neo4j.driver.AuthTokens; @@ -64,8 +63,7 @@ public class Neo4jAutoConfiguration { public Driver neo4jDriver(Neo4jProperties properties, Environment environment, ObjectProvider configBuilderCustomizers) { AuthToken authToken = mapAuthToken(properties.getAuthentication(), environment); - Config config = mapDriverConfig(properties, - configBuilderCustomizers.orderedStream().collect(Collectors.toList())); + Config config = mapDriverConfig(properties, configBuilderCustomizers.orderedStream().toList()); URI serverUri = determineServerUri(properties, environment); return GraphDatabase.driver(serverUri, authToken, config); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java index 01a8fa29fd..0eebeff1c5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -23,7 +23,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Supplier; -import java.util.stream.Collectors; import javax.sql.DataSource; @@ -99,7 +98,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration { this.poolMetadataProvider = new CompositeDataSourcePoolMetadataProvider(metadataProviders.getIfAvailable()); this.hibernatePropertiesCustomizers = determineHibernatePropertiesCustomizers( physicalNamingStrategy.getIfAvailable(), implicitNamingStrategy.getIfAvailable(), beanFactory, - hibernatePropertiesCustomizers.orderedStream().collect(Collectors.toList())); + hibernatePropertiesCustomizers.orderedStream().toList()); } private List determineHibernatePropertiesCustomizers( diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations.java index e0c271a555..ffdb6f1e1c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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.boot.autoconfigure.r2dbc; import java.util.List; -import java.util.stream.Collectors; import io.r2dbc.pool.ConnectionPool; import io.r2dbc.pool.ConnectionPoolConfiguration; @@ -90,7 +89,7 @@ abstract class ConnectionFactoryConfigurations { ConnectionPool connectionFactory(R2dbcProperties properties, ResourceLoader resourceLoader, ObjectProvider customizers) { ConnectionFactory connectionFactory = createConnectionFactory(properties, - resourceLoader.getClassLoader(), customizers.orderedStream().collect(Collectors.toList())); + resourceLoader.getClassLoader(), customizers.orderedStream().toList()); R2dbcProperties.Pool pool = properties.getPool(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); ConnectionPoolConfiguration.Builder builder = ConnectionPoolConfiguration.builder(connectionFactory); @@ -119,7 +118,7 @@ abstract class ConnectionFactoryConfigurations { ConnectionFactory connectionFactory(R2dbcProperties properties, ResourceLoader resourceLoader, ObjectProvider customizers) { return createConnectionFactory(properties, resourceLoader.getClassLoader(), - customizers.orderedStream().collect(Collectors.toList())); + customizers.orderedStream().toList()); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java index f8e33e21ad..ff7aef026f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.rsocket; -import java.util.stream.Collectors; - import io.rsocket.core.RSocketServer; import io.rsocket.frame.decoder.PayloadDecoder; import io.rsocket.transport.netty.server.TcpServerTransport; @@ -99,7 +97,7 @@ public class RSocketServerAutoConfiguration { map.from(properties.getServer().getPort()).to(factory::setPort); map.from(properties.getServer().getFragmentSize()).to(factory::setFragmentSize); map.from(properties.getServer().getSsl()).to(factory::setSsl); - factory.setRSocketServerCustomizers(customizers.orderedStream().collect(Collectors.toList())); + factory.setRSocketServerCustomizers(customizers.orderedStream().toList()); return factory; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketWebSocketNettyRouteProvider.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketWebSocketNettyRouteProvider.java index d34935ea67..5cb8d7f374 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketWebSocketNettyRouteProvider.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketWebSocketNettyRouteProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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.boot.autoconfigure.rsocket; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import io.rsocket.SocketAcceptor; @@ -46,7 +45,7 @@ class RSocketWebSocketNettyRouteProvider implements NettyRouteProvider { Stream customizers) { this.mappingPath = mappingPath; this.socketAcceptor = socketAcceptor; - this.customizers = customizers.collect(Collectors.toList()); + this.customizers = customizers.toList(); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java index a1609fa952..7d95c338c3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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,7 @@ package org.springframework.boot.autoconfigure.security.reactive; import java.util.EnumSet; import java.util.LinkedHashSet; -import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; import reactor.core.publisher.Mono; @@ -123,18 +121,17 @@ public final class StaticResourceRequest { return new StaticResourceServerWebExchange(subset); } - private List getDelegateMatchers() { - return getPatterns().map(PathPatternParserServerWebExchangeMatcher::new).collect(Collectors.toList()); - } - private Stream getPatterns() { return this.locations.stream().flatMap(StaticResourceLocation::getPatterns); } @Override public Mono matches(ServerWebExchange exchange) { - OrServerWebExchangeMatcher matcher = new OrServerWebExchangeMatcher(getDelegateMatchers()); - return matcher.matches(exchange); + return new OrServerWebExchangeMatcher(getDelegateMatchers().toList()).matches(exchange); + } + + private Stream getDelegateMatchers() { + return getPatterns().map(PathPatternParserServerWebExchangeMatcher::new); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java index 8e188a1276..fa865639f1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java @@ -23,7 +23,6 @@ import java.security.interfaces.RSAPrivateKey; import java.util.List; import java.util.Map; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.AssertingParty; @@ -64,7 +63,7 @@ class Saml2RelyingPartyRegistrationConfiguration { @Bean RelyingPartyRegistrationRepository relyingPartyRegistrationRepository(Saml2RelyingPartyProperties properties) { List registrations = properties.getRegistration().entrySet().stream() - .map(this::asRegistration).collect(Collectors.toList()); + .map(this::asRegistration).toList(); return new InMemoryRelyingPartyRegistrationRepository(registrations); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequest.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequest.java index 09f060cd19..3b53dacddf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequest.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/StaticResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,8 @@ package org.springframework.boot.autoconfigure.security.servlet; import java.util.EnumSet; import java.util.LinkedHashSet; -import java.util.List; import java.util.Set; import java.util.function.Supplier; -import java.util.stream.Collectors; import java.util.stream.Stream; import jakarta.servlet.http.HttpServletRequest; @@ -134,11 +132,11 @@ public final class StaticResourceRequest { @Override protected void initialized(Supplier dispatcherServletPath) { - this.delegate = new OrRequestMatcher(getDelegateMatchers(dispatcherServletPath.get())); + this.delegate = new OrRequestMatcher(getDelegateMatchers(dispatcherServletPath.get()).toList()); } - private List getDelegateMatchers(DispatcherServletPath dispatcherServletPath) { - return getPatterns(dispatcherServletPath).map(AntPathRequestMatcher::new).collect(Collectors.toList()); + private Stream getDelegateMatchers(DispatcherServletPath dispatcherServletPath) { + return getPatterns(dispatcherServletPath).map(AntPathRequestMatcher::new); } private Stream getPatterns(DispatcherServletPath dispatcherServletPath) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.java index 2a9e109d80..83c46e8a25 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.transaction; -import java.util.stream.Collectors; - import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -58,7 +56,7 @@ public class TransactionAutoConfiguration { @ConditionalOnMissingBean public TransactionManagerCustomizers platformTransactionManagerCustomizers( ObjectProvider> customizers) { - return new TransactionManagerCustomizers(customizers.orderedStream().collect(Collectors.toList())); + return new TransactionManagerCustomizers(customizers.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.java index 0cca74e060..bbefd47fcc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.web.client; -import java.util.stream.Collectors; - import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -58,9 +56,8 @@ public class RestTemplateAutoConfiguration { ObjectProvider> restTemplateRequestCustomizers) { RestTemplateBuilderConfigurer configurer = new RestTemplateBuilderConfigurer(); configurer.setHttpMessageConverters(messageConverters.getIfUnique()); - configurer.setRestTemplateCustomizers(restTemplateCustomizers.orderedStream().collect(Collectors.toList())); - configurer.setRestTemplateRequestCustomizers( - restTemplateRequestCustomizers.orderedStream().collect(Collectors.toList())); + configurer.setRestTemplateCustomizers(restTemplateCustomizers.orderedStream().toList()); + configurer.setRestTemplateRequestCustomizers(restTemplateRequestCustomizers.orderedStream().toList()); return configurer; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration.java index 6ec994d776..b14d1acd3c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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,6 @@ package org.springframework.boot.autoconfigure.web.reactive; -import java.util.stream.Collectors; - import io.undertow.Undertow; import org.eclipse.jetty.servlet.ServletHolder; import reactor.netty.http.server.HttpServer; @@ -71,7 +69,7 @@ abstract class ReactiveWebServerFactoryConfiguration { NettyReactiveWebServerFactory serverFactory = new NettyReactiveWebServerFactory(); serverFactory.setResourceFactory(resourceFactory); routes.orderedStream().forEach(serverFactory::addRouteProviders); - serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().collect(Collectors.toList())); + serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().toList()); return serverFactory; } @@ -88,12 +86,9 @@ abstract class ReactiveWebServerFactoryConfiguration { ObjectProvider contextCustomizers, ObjectProvider> protocolHandlerCustomizers) { TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory(); - factory.getTomcatConnectorCustomizers() - .addAll(connectorCustomizers.orderedStream().collect(Collectors.toList())); - factory.getTomcatContextCustomizers() - .addAll(contextCustomizers.orderedStream().collect(Collectors.toList())); - factory.getTomcatProtocolHandlerCustomizers() - .addAll(protocolHandlerCustomizers.orderedStream().collect(Collectors.toList())); + factory.getTomcatConnectorCustomizers().addAll(connectorCustomizers.orderedStream().toList()); + factory.getTomcatContextCustomizers().addAll(contextCustomizers.orderedStream().toList()); + factory.getTomcatProtocolHandlerCustomizers().addAll(protocolHandlerCustomizers.orderedStream().toList()); return factory; } @@ -114,7 +109,7 @@ abstract class ReactiveWebServerFactoryConfiguration { JettyReactiveWebServerFactory jettyReactiveWebServerFactory(JettyResourceFactory resourceFactory, ObjectProvider serverCustomizers) { JettyReactiveWebServerFactory serverFactory = new JettyReactiveWebServerFactory(); - serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().collect(Collectors.toList())); + serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().toList()); serverFactory.setResourceFactory(resourceFactory); return serverFactory; } @@ -130,7 +125,7 @@ abstract class ReactiveWebServerFactoryConfiguration { UndertowReactiveWebServerFactory undertowReactiveWebServerFactory( ObjectProvider builderCustomizers) { UndertowReactiveWebServerFactory factory = new UndertowReactiveWebServerFactory(); - factory.getBuilderCustomizers().addAll(builderCustomizers.orderedStream().collect(Collectors.toList())); + factory.getBuilderCustomizers().addAll(builderCustomizers.orderedStream().toList()); return factory; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.java index 7044688ab7..df38fcaac6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.web.reactive.error; -import java.util.stream.Collectors; - import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -67,7 +65,7 @@ public class ErrorWebFluxAutoConfiguration { ServerCodecConfigurer serverCodecConfigurer, ApplicationContext applicationContext) { DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, webProperties.getResources(), this.serverProperties.getError(), applicationContext); - exceptionHandler.setViewResolvers(viewResolvers.orderedStream().collect(Collectors.toList())); + exceptionHandler.setViewResolvers(viewResolvers.orderedStream().toList()); exceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters()); exceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders()); return exceptionHandler; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.java index 2e69e67aa5..e9545c5753 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.web.reactive.function.client; -import java.util.stream.Collectors; - import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -65,7 +63,7 @@ public class WebClientAutoConfiguration { @ConditionalOnMissingBean @Order(0) public WebClientCodecCustomizer exchangeStrategiesCustomizer(ObjectProvider codecCustomizers) { - return new WebClientCodecCustomizer(codecCustomizers.orderedStream().collect(Collectors.toList())); + return new WebClientCodecCustomizer(codecCustomizers.orderedStream().toList()); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.java index ea9a919c06..624383b59a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.java @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.web.servlet; import java.util.function.Supplier; -import java.util.stream.Collectors; import jakarta.servlet.DispatcherType; import jakarta.servlet.ServletRequest; @@ -77,9 +76,8 @@ public class ServletWebServerFactoryAutoConfiguration { public ServletWebServerFactoryCustomizer servletWebServerFactoryCustomizer(ServerProperties serverProperties, ObjectProvider webListenerRegistrars, ObjectProvider cookieSameSiteSuppliers) { - return new ServletWebServerFactoryCustomizer(serverProperties, - webListenerRegistrars.orderedStream().collect(Collectors.toList()), - cookieSameSiteSuppliers.orderedStream().collect(Collectors.toList())); + return new ServletWebServerFactoryCustomizer(serverProperties, webListenerRegistrars.orderedStream().toList(), + cookieSameSiteSuppliers.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration.java index 82725b8783..2e2097f678 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.web.servlet; -import java.util.stream.Collectors; - import io.undertow.Undertow; import jakarta.servlet.Servlet; import org.apache.catalina.startup.Tomcat; @@ -73,12 +71,9 @@ class ServletWebServerFactoryConfiguration { ObjectProvider contextCustomizers, ObjectProvider> protocolHandlerCustomizers) { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); - factory.getTomcatConnectorCustomizers() - .addAll(connectorCustomizers.orderedStream().collect(Collectors.toList())); - factory.getTomcatContextCustomizers() - .addAll(contextCustomizers.orderedStream().collect(Collectors.toList())); - factory.getTomcatProtocolHandlerCustomizers() - .addAll(protocolHandlerCustomizers.orderedStream().collect(Collectors.toList())); + factory.getTomcatConnectorCustomizers().addAll(connectorCustomizers.orderedStream().toList()); + factory.getTomcatContextCustomizers().addAll(contextCustomizers.orderedStream().toList()); + factory.getTomcatProtocolHandlerCustomizers().addAll(protocolHandlerCustomizers.orderedStream().toList()); return factory; } @@ -96,7 +91,7 @@ class ServletWebServerFactoryConfiguration { JettyServletWebServerFactory JettyServletWebServerFactory( ObjectProvider serverCustomizers) { JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); - factory.getServerCustomizers().addAll(serverCustomizers.orderedStream().collect(Collectors.toList())); + factory.getServerCustomizers().addAll(serverCustomizers.orderedStream().toList()); return factory; } @@ -115,9 +110,8 @@ class ServletWebServerFactoryConfiguration { ObjectProvider deploymentInfoCustomizers, ObjectProvider builderCustomizers) { UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory(); - factory.getDeploymentInfoCustomizers() - .addAll(deploymentInfoCustomizers.orderedStream().collect(Collectors.toList())); - factory.getBuilderCustomizers().addAll(builderCustomizers.orderedStream().collect(Collectors.toList())); + factory.getDeploymentInfoCustomizers().addAll(deploymentInfoCustomizers.orderedStream().toList()); + factory.getBuilderCustomizers().addAll(builderCustomizers.orderedStream().toList()); return factory; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java index ecb21b93fa..df4eae0b6e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web.servlet.error; import java.nio.charset.StandardCharsets; import java.util.Map; -import java.util.stream.Collectors; import jakarta.servlet.Servlet; import jakarta.servlet.http.HttpServletRequest; @@ -107,7 +106,7 @@ public class ErrorMvcAutoConfiguration { public BasicErrorController basicErrorController(ErrorAttributes errorAttributes, ObjectProvider errorViewResolvers) { return new BasicErrorController(errorAttributes, this.serverProperties.getError(), - errorViewResolvers.orderedStream().collect(Collectors.toList())); + errorViewResolvers.orderedStream().toList()); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/client/WebServiceTemplateAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/client/WebServiceTemplateAutoConfiguration.java index 65f59c7dd2..e07363e477 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/client/WebServiceTemplateAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/client/WebServiceTemplateAutoConfiguration.java @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.webservices.client; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -46,8 +45,7 @@ public class WebServiceTemplateAutoConfiguration { public WebServiceTemplateBuilder webServiceTemplateBuilder( ObjectProvider webServiceTemplateCustomizers) { WebServiceTemplateBuilder builder = new WebServiceTemplateBuilder(); - List customizers = webServiceTemplateCustomizers.orderedStream() - .collect(Collectors.toList()); + List customizers = webServiceTemplateCustomizers.orderedStream().toList(); if (!customizers.isEmpty()) { builder = builder.customizers(customizers); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java index 30f01bca46..e9ad03ec02 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java @@ -21,7 +21,6 @@ import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.sql.DataSource; @@ -87,7 +86,7 @@ class BatchDataSourceScriptDatabaseInitializerTests { List schemaNames = Stream .of(resolver.getResources("classpath:org/springframework/batch/core/schema-*.sql")) .map((resource) -> resource.getFilename()).filter((resourceName) -> !resourceName.contains("-drop-")) - .collect(Collectors.toList()); + .toList(); assertThat(schemaNames).containsExactlyInAnyOrder("schema-derby.sql", "schema-sqlserver.sql", "schema-mysql.sql", "schema-sqlite.sql", "schema-postgresql.sql", "schema-hana.sql", "schema-oracle.sql", "schema-db2.sql", "schema-hsqldb.sql", "schema-sybase.sql", "schema-h2.sql"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersTests.java index 103bbf3962..6d8f341d59 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.http; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; +import java.util.stream.Stream; import org.junit.jupiter.api.Test; @@ -84,8 +84,7 @@ class HttpMessageConvertersTests { void addBeforeExistingEquivalentConverter() { GsonHttpMessageConverter converter1 = new GsonHttpMessageConverter(); HttpMessageConverters converters = new HttpMessageConverters(converter1); - List> converterClasses = converters.getConverters().stream().map(HttpMessageConverter::getClass) - .collect(Collectors.toList()); + Stream> converterClasses = converters.getConverters().stream().map(HttpMessageConverter::getClass); assertThat(converterClasses).containsSequence(GsonHttpMessageConverter.class, MappingJackson2HttpMessageConverter.class); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfigurationTests.java index 63b4b8692a..1d7c3a11e6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfigurationTests.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.security.oauth2.client.servlet; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import jakarta.servlet.Filter; import org.junit.jupiter.api.Test; @@ -169,7 +168,7 @@ class OAuth2WebSecurityConfigurationTests { FilterChainProxy filterChain = (FilterChainProxy) context.getBean(BeanIds.SPRING_SECURITY_FILTER_CHAIN); List filterChains = filterChain.getFilterChains(); List filters = filterChains.get(0).getFilters(); - return filters.stream().filter(filter::isInstance).collect(Collectors.toList()); + return filters.stream().filter(filter::isInstance).toList(); } private boolean isEqual(ClientRegistration reg1, ClientRegistration reg2) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java index db30924210..7746d13018 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java @@ -24,7 +24,6 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.SynchronousQueue; -import java.util.stream.Collectors; import org.eclipse.jetty.server.AbstractConnector; import org.eclipse.jetty.server.Connector; @@ -296,8 +295,7 @@ class JettyWebServerFactoryCustomizerTests { server.start(); server.stop(); return Arrays.stream(server.getServer().getConnectors()) - .filter((connector) -> connector instanceof AbstractConnector).map(Connector::getIdleTimeout) - .collect(Collectors.toList()); + .filter((connector) -> connector instanceof AbstractConnector).map(Connector::getIdleTimeout).toList(); } private List getRequestHeaderSizes(JettyWebServer server) { diff --git a/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/AbstractApplicationLauncher.java b/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/AbstractApplicationLauncher.java index 67b7366088..085182163b 100644 --- a/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/AbstractApplicationLauncher.java +++ b/spring-boot-project/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/AbstractApplicationLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,6 @@ package org.springframework.boot.devtools.tests; import java.io.File; import java.io.IOException; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.util.FileSystemUtils; @@ -45,8 +44,7 @@ abstract class AbstractApplicationLauncher implements ApplicationLauncher { } protected final List getDependencyJarPaths() { - return Stream.of(this.directories.getDependenciesDirectory().listFiles()).map(File::getAbsolutePath) - .collect(Collectors.toList()); + return Stream.of(this.directories.getDependenciesDirectory().listFiles()).map(File::getAbsolutePath).toList(); } protected final Directories getDirectories() { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java index 7d86444bfe..0f7cc86aab 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java @@ -36,11 +36,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import java.util.stream.Collectors; +import java.util.stream.Stream; import jakarta.websocket.ClientEndpointConfig; import jakarta.websocket.ClientEndpointConfig.Configurator; import jakarta.websocket.Endpoint; +import jakarta.websocket.Extension; import jakarta.websocket.HandshakeResponse; import jakarta.websocket.WebSocketContainer; import org.apache.tomcat.websocket.WsWebSocketContainer; @@ -300,11 +301,10 @@ class LiveReloadServerTests { InetSocketAddress remoteAddress = new InetSocketAddress(uri.getHost(), uri.getPort()); StandardWebSocketSession session = new StandardWebSocketSession(headers, attributes, localAddress, remoteAddress); + Stream adaptedExtensions = extensions.stream().map(WebSocketToStandardExtensionAdapter::new); ClientEndpointConfig endpointConfig = ClientEndpointConfig.Builder.create() .configurator(new UppercaseWebSocketClientConfigurator(headers)).preferredSubprotocols(protocols) - .extensions(extensions.stream().map(WebSocketToStandardExtensionAdapter::new) - .collect(Collectors.toList())) - .build(); + .extensions(adaptedExtensions.toList()).build(); endpointConfig.getUserProperties().putAll(getUserProperties()); Endpoint endpoint = new StandardWebSocketHandlerAdapter(webSocketHandler, session); Callable connectTask = () -> { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfiguration.java index 816ebc0102..279397ceed 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfiguration.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfiguration.java @@ -17,7 +17,6 @@ package org.springframework.boot.test.autoconfigure.web.reactive; import java.util.List; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -71,8 +70,7 @@ public class WebTestClientAutoConfiguration { @ConfigurationProperties(prefix = "spring.test.webtestclient") public SpringBootWebTestClientBuilderCustomizer springBootWebTestClientBuilderCustomizer( ObjectProvider codecCustomizers) { - return new SpringBootWebTestClientBuilderCustomizer( - codecCustomizers.orderedStream().collect(Collectors.toList())); + return new SpringBootWebTestClientBuilderCustomizer(codecCustomizers.orderedStream().toList()); } } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java index 53dd092ae4..e7e3702e02 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java @@ -16,6 +16,7 @@ package org.springframework.boot.test.context; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -143,7 +144,7 @@ class SpringBootContextLoaderTests { ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getApplicationContext() .getEnvironment(); List names = environment.getPropertySources().stream().map(PropertySource::getName) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ArrayList::new)); String last = names.remove(names.size() - 1); assertThat(names).containsExactly("configurationProperties", "Inlined Test Properties", "commandLineArgs", "servletConfigInitParams", "servletContextInitParams", "systemProperties", "systemEnvironment", diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index bf488814f0..094418926c 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -20,8 +20,7 @@ import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URI; -import java.util.List; -import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.hc.client5.http.config.RequestConfig; import org.junit.jupiter.api.Test; @@ -203,7 +202,7 @@ class TestRestTemplateTests { void withBasicAuthAddsBasicAuthWhenNotAlreadyPresent() { TestRestTemplate original = new TestRestTemplate(); TestRestTemplate basicAuth = original.withBasicAuth("user", "password"); - assertThat(getConverterClasses(original)).containsExactlyElementsOf(getConverterClasses(basicAuth)); + assertThat(getConverterClasses(original)).containsExactlyElementsOf(getConverterClasses(basicAuth).toList()); assertThat(basicAuth.getRestTemplate().getInterceptors()).isEmpty(); assertBasicAuthorizationCredentials(original, null, null); assertBasicAuthorizationCredentials(basicAuth, "user", "password"); @@ -213,14 +212,13 @@ class TestRestTemplateTests { void withBasicAuthReplacesBasicAuthWhenAlreadyPresent() { TestRestTemplate original = new TestRestTemplate("foo", "bar").withBasicAuth("replace", "replace"); TestRestTemplate basicAuth = original.withBasicAuth("user", "password"); - assertThat(getConverterClasses(basicAuth)).containsExactlyElementsOf(getConverterClasses(original)); + assertThat(getConverterClasses(basicAuth)).containsExactlyElementsOf(getConverterClasses(original).toList()); assertBasicAuthorizationCredentials(original, "replace", "replace"); assertBasicAuthorizationCredentials(basicAuth, "user", "password"); } - private List> getConverterClasses(TestRestTemplate testRestTemplate) { - return testRestTemplate.getRestTemplate().getMessageConverters().stream().map(Object::getClass) - .collect(Collectors.toList()); + private Stream> getConverterClasses(TestRestTemplate testRestTemplate) { + return testRestTemplate.getRestTemplate().getMessageConverters().stream().map(Object::getClass); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/Image.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/Image.java index 4864fe3d53..bbcd5cba97 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/Image.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/Image.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import com.fasterxml.jackson.databind.JsonNode; @@ -66,7 +65,7 @@ public class Image extends MappedObject { if (layers == null) { return Collections.emptyList(); } - return Collections.unmodifiableList(Arrays.stream(layers).map(LayerId::of).collect(Collectors.toList())); + return Arrays.stream(layers).map(LayerId::of).toList(); } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-cli/src/intTest/java/org/springframework/boot/cli/infrastructure/CommandLineInvoker.java b/spring-boot-project/spring-boot-tools/spring-boot-cli/src/intTest/java/org/springframework/boot/cli/infrastructure/CommandLineInvoker.java index f6b56eb015..1bed2004b7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-cli/src/intTest/java/org/springframework/boot/cli/infrastructure/CommandLineInvoker.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-cli/src/intTest/java/org/springframework/boot/cli/infrastructure/CommandLineInvoker.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -32,7 +32,6 @@ import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -170,7 +169,7 @@ public final class CommandLineInvoker { private List getLines(StringBuffer buffer) { BufferedReader reader = new BufferedReader(new StringReader(buffer.toString())); - return reader.lines().filter((line) -> !line.startsWith("Picked up ")).collect(Collectors.toList()); + return reader.lines().filter((line) -> !line.startsWith("Picked up ")).toList(); } public int await() throws InterruptedException { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptor.java index dfc6f00653..c95e27c16c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptor.java @@ -19,7 +19,6 @@ package org.springframework.boot.configurationprocessor; import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.stream.Collectors; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; @@ -69,8 +68,7 @@ class ConstructorParameterPropertyDescriptor extends PropertyDescriptor coerceValue(specificType, value)) - .collect(Collectors.toList()); + return defaultValue.stream().map((value) -> coerceValue(specificType, value)).toList(); } catch (IllegalArgumentException ex) { environment.getMessager().printMessage(Kind.ERROR, ex.getMessage(), element, annotation); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java index 618b169059..c5389993a7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.lang.model.element.AnnotationMirror; @@ -202,7 +201,7 @@ class PropertyDescriptorResolver { if (bindConstructor != null) { return Collections.singletonList(bindConstructor); } - return constructors.stream().filter(env::hasConstructorBindingAnnotation).collect(Collectors.toList()); + return constructors.stream().filter(env::hasConstructorBindingAnnotation).toList(); } private static ExecutableElement deduceBindConstructor(List constructors, diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonConverter.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonConverter.java index de97b71f32..4eb816385b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonConverter.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.springframework.boot.configurationprocessor.json.JSONArray; import org.springframework.boot.configurationprocessor.json.JSONObject; @@ -40,7 +39,7 @@ class JsonConverter { JSONArray toJsonArray(ConfigurationMetadata metadata, ItemType itemType) throws Exception { JSONArray jsonArray = new JSONArray(); List items = metadata.getItems().stream().filter((item) -> item.isOfItemType(itemType)) - .sorted(ITEM_COMPARATOR).collect(Collectors.toList()); + .sorted(ITEM_COMPARATOR).toList(); for (ItemMetadata item : items) { if (item.isOfItemType(itemType)) { jsonArray.put(toJsonObject(item)); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptorTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptorTests.java index c4a01ad1ca..8b3918c3e4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptorTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConstructorParameterPropertyDescriptorTests.java @@ -19,7 +19,6 @@ package org.springframework.boot.configurationprocessor; import java.io.IOException; import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -223,7 +222,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest private VariableElement getConstructorParameter(TypeElement ownerElement, String name) { List constructors = ElementFilter.constructorsIn(ownerElement.getEnclosedElements()).stream() - .filter((constructor) -> !constructor.getParameters().isEmpty()).collect(Collectors.toList()); + .filter((constructor) -> !constructor.getParameters().isEmpty()).toList(); if (constructors.size() != 1) { throw new IllegalStateException("No candidate constructor for " + ownerElement); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MergeMetadataGenerationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MergeMetadataGenerationTests.java index 573e8add84..cdeb4636f8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MergeMetadataGenerationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MergeMetadataGenerationTests.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -87,7 +86,7 @@ class MergeMetadataGenerationTests extends AbstractMetadataGenerationTests { SimpleConflictingProperties.class); assertThat(metadata.getItems()).hasSize(6); List items = metadata.getItems().stream().filter((item) -> item.getName().equals("simple.flag")) - .collect(Collectors.toList()); + .toList(); assertThat(items).hasSize(2); ItemMetadata matchingProperty = items.stream().filter((item) -> item.getType().equals(Boolean.class.getName())) .findFirst().orElse(null); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/Metadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/Metadata.java index 49faa351a4..ec383d0954 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/Metadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/Metadata.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.assertj.core.api.Condition; import org.hamcrest.collection.IsMapContaining; @@ -210,8 +209,7 @@ public final class Metadata { private ItemMetadata findItem(ConfigurationMetadata metadata, String name) { List candidates = metadata.getItems().stream() - .filter((item) -> item.isOfItemType(this.itemType) && name.equals(item.getName())) - .collect(Collectors.toList()); + .filter((item) -> item.isOfItemType(this.itemType) && name.equals(item.getName())).toList(); if (candidates.size() > 1) { throw new IllegalStateException("More than one metadata item with name '" + name + "': " + candidates); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java index 69b6d926ed..17a47d4349 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.gradle.api.Action; import org.gradle.api.DefaultTask; @@ -580,7 +579,7 @@ public class BootBuildImage extends DefaultTask { private BuildRequest customizeBuildpacks(BuildRequest request) { List buildpacks = this.buildpacks.getOrNull(); if (buildpacks != null && !buildpacks.isEmpty()) { - return request.withBuildpacks(buildpacks.stream().map(BuildpackReference::of).collect(Collectors.toList())); + return request.withBuildpacks(buildpacks.stream().map(BuildpackReference::of).toList()); } return request; } @@ -588,7 +587,7 @@ public class BootBuildImage extends DefaultTask { private BuildRequest customizeBindings(BuildRequest request) { List bindings = this.bindings.getOrNull(); if (bindings != null && !bindings.isEmpty()) { - return request.withBindings(bindings.stream().map(Binding::of).collect(Collectors.toList())); + return request.withBindings(bindings.stream().map(Binding::of).toList()); } return request; } @@ -596,7 +595,7 @@ public class BootBuildImage extends DefaultTask { private BuildRequest customizeTags(BuildRequest request) { List tags = this.tags.getOrNull(); if (tags != null && !tags.isEmpty()) { - return request.withTags(tags.stream().map(ImageReference::of).collect(Collectors.toList())); + return request.withTags(tags.stream().map(ImageReference::of).toList()); } return request; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java index 39e512ec6d..fe83bceea3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.zip.CRC32; import java.util.zip.ZipEntry; @@ -322,8 +321,7 @@ class BootZipCopyAction implements CopyAction { Attributes manifestAttributes = BootZipCopyAction.this.manifest.getAttributes(); String classPathIndex = (String) manifestAttributes.get("Spring-Boot-Classpath-Index"); if (classPathIndex != null) { - List lines = this.writtenLibraries.stream().map((line) -> "- \"" + line + "\"") - .collect(Collectors.toList()); + List lines = this.writtenLibraries.stream().map((line) -> "- \"" + line + "\"").toList(); writeEntry(classPathIndex, ZipEntryContentWriter.fromLines(BootZipCopyAction.this.encoding, lines), true); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java index 45290aa63f..e2f6e70fd8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -208,7 +208,7 @@ public class LayeredSpec { "The 'layerOrder' must be defined when using custom layering"); return Layers.IMPLICIT; } - List layers = this.layerOrder.stream().map(Layer::new).collect(Collectors.toList()); + List layers = this.layerOrder.stream().map(Layer::new).toList(); return new CustomLayers(layers, this.application.asSelectors(), this.dependencies.asSelectors()); } @@ -242,7 +242,7 @@ public class LayeredSpec { } List> asSelectors(Function> selectorFactory) { - return this.intoLayers.stream().map(selectorFactory).collect(Collectors.toList()); + return this.intoLayers.stream().map(selectorFactory).toList(); } } @@ -350,15 +350,13 @@ public class LayeredSpec { ContentSelector asLibrarySelector(Function> filterFactory) { Layer layer = new Layer(getIntoLayer()); List> includeFilters = getIncludes().stream().map(filterFactory) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ArrayList::new)); if (this.includeProjectDependencies) { - includeFilters = new ArrayList<>(includeFilters); includeFilters.add(Library::isLocal); } List> excludeFilters = getExcludes().stream().map(filterFactory) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ArrayList::new)); if (this.excludeProjectDependencies) { - excludeFilters = new ArrayList<>(excludeFilters); excludeFilters.add(Library::isLocal); } return new IncludeExcludeContentSelector<>(layer, includeFilters, excludeFilters); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java index b7dc7e1122..b112b481d1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java @@ -41,7 +41,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipEntry; @@ -577,9 +576,8 @@ abstract class AbstractBootArchiveIntegrationTests { for (String layerName : layerNames) { File layer = new File(root, layerName); assertThat(layer).isDirectory(); - extractedLayers.put(layerName, - Files.walk(layer.toPath()).filter((path) -> path.toFile().isFile()).map(layer.toPath()::relativize) - .map(Path::toString).map(StringUtils::cleanPath).collect(Collectors.toList())); + extractedLayers.put(layerName, Files.walk(layer.toPath()).filter((path) -> path.toFile().isFile()) + .map(layer.toPath()::relativize).map(Path::toString).map(StringUtils::cleanPath).toList()); } return extractedLayers; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java index 13cd42238b..14c7859cf5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java @@ -39,7 +39,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -720,7 +719,7 @@ abstract class AbstractBootArchiveTests { List entryLines(JarFile jarFile, String entryName) throws IOException { try (BufferedReader reader = new BufferedReader( new InputStreamReader(jarFile.getInputStream(jarFile.getEntry(entryName))))) { - return reader.lines().collect(Collectors.toList()); + return reader.lines().toList(); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java index 68c1535ea5..8bd502df66 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java @@ -31,7 +31,6 @@ import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; -import java.util.stream.Collectors; import org.apache.commons.compress.archivers.jar.JarArchiveEntry; @@ -510,7 +509,7 @@ public abstract class Packager { private void writeClasspathIndexIfNecessary(List paths, Layout layout, AbstractJarWriter writer) throws IOException { if (layout.getClasspathIndexFileLocation() != null) { - List names = paths.stream().map((path) -> "- \"" + path + "\"").collect(Collectors.toList()); + List names = paths.stream().map((path) -> "- \"" + path + "\"").toList(); writer.writeIndexFile(layout.getClasspathIndexFileLocation(), names); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/layer/IncludeExcludeContentSelector.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/layer/IncludeExcludeContentSelector.java index 194a57a3e2..947f3959d2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/layer/IncludeExcludeContentSelector.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/layer/IncludeExcludeContentSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,6 @@ package org.springframework.boot.loader.tools.layer; import java.util.Collections; import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; import org.springframework.boot.loader.tools.Layer; import org.springframework.util.Assert; @@ -56,7 +55,7 @@ public class IncludeExcludeContentSelector implements ContentSelector { } private List> adapt(List list, Function> mapper) { - return list.stream().map(mapper).collect(Collectors.toList()); + return list.stream().map(mapper).toList(); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java index 25806851a4..5b8bf8e2b5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java @@ -234,7 +234,7 @@ abstract class AbstractPackagerTests

{ String index = getPackagedEntryContent("BOOT-INF/classpath.idx"); String[] libraries = index.split("\\r?\\n"); List expected = Stream.of(libJarFile1, libJarFile2, libJarFile3) - .map((jar) -> "- \"BOOT-INF/lib/" + jar.getName() + "\"").collect(Collectors.toList()); + .map((jar) -> "- \"BOOT-INF/lib/" + jar.getName() + "\"").toList(); assertThat(Arrays.asList(libraries)).containsExactlyElementsOf(expected); } @@ -265,7 +265,7 @@ abstract class AbstractPackagerTests

{ assertThat(hasPackagedEntry("BOOT-INF/classpath.idx")).isTrue(); String classpathIndex = getPackagedEntryContent("BOOT-INF/classpath.idx"); List expectedClasspathIndex = Stream.of(libJarFile1, libJarFile2, libJarFile3) - .map((file) -> "- \"BOOT-INF/lib/" + file.getName() + "\"").collect(Collectors.toList()); + .map((file) -> "- \"BOOT-INF/lib/" + file.getName() + "\"").toList(); assertThat(Arrays.asList(classpathIndex.split("\\n"))).containsExactlyElementsOf(expectedClasspathIndex); assertThat(hasPackagedEntry("BOOT-INF/layers.idx")).isTrue(); String layersIndex = getPackagedEntryContent("BOOT-INF/layers.idx"); @@ -637,7 +637,8 @@ abstract class AbstractPackagerTests

{ protected abstract void execute(P packager, Libraries libraries) throws IOException; protected Collection getPackagedEntryNames() throws IOException { - return getAllPackagedEntries().stream().map(ZipArchiveEntry::getName).collect(Collectors.toList()); + return getAllPackagedEntries().stream().map(ZipArchiveEntry::getName) + .collect(Collectors.toCollection(ArrayList::new)); } protected boolean hasPackagedLauncherClasses() throws IOException { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java index f3deb7b0d7..c08407941b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ClassPathIndexFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -29,7 +29,6 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; /** * A class path index file that provides ordering information for JARs. @@ -45,7 +44,7 @@ final class ClassPathIndexFile { private ClassPathIndexFile(File root, List lines) { this.root = root; - this.lines = lines.stream().map(this::extractName).collect(Collectors.toList()); + this.lines = lines.stream().map(this::extractName).toList(); } private String extractName(String line) { @@ -67,7 +66,7 @@ final class ClassPathIndexFile { } List getUrls() { - return Collections.unmodifiableList(this.lines.stream().map(this::asUrl).collect(Collectors.toList())); + return this.lines.stream().map(this::asUrl).toList(); } private URL asUrl(String line) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java index c01259c8ba..3b0ab0f14e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -22,7 +22,6 @@ import java.io.InputStream; import java.net.URL; import java.util.List; import java.util.jar.JarEntry; -import java.util.stream.Collectors; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -207,7 +206,7 @@ class JarURLConnectionTests { void entriesCanBeStreamedFromJarFileOfConnection() throws Exception { URL url = new URL("jar:" + this.rootJarFile.toURI().toURL() + "!/"); JarURLConnection connection = JarURLConnection.get(url, this.jarFile); - List entryNames = connection.getJarFile().stream().map(JarEntry::getName).collect(Collectors.toList()); + List entryNames = connection.getJarFile().stream().map(JarEntry::getName).toList(); assertThat(entryNames).hasSize(12); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java index 427719ca22..28d8b30112 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java @@ -30,7 +30,6 @@ import java.util.function.Consumer; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipEntry; @@ -179,10 +178,8 @@ abstract class AbstractArchiveIntegrationTests { ListAssert entryNamesInPath(String path) { List matches = new ArrayList<>(); - withJarFile((jarFile) -> withEntries(jarFile, - (entries) -> matches.addAll(entries.map(ZipEntry::getName) - .filter((name) -> name.startsWith(path) && name.length() > path.length()) - .collect(Collectors.toList())))); + withJarFile((jarFile) -> withEntries(jarFile, (entries) -> matches.addAll(entries.map(ZipEntry::getName) + .filter((name) -> name.startsWith(path) && name.length() > path.length()).toList()))); return new ListAssert<>(matches); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java index 48d64ff67c..183549a560 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.jar.JarFile; -import java.util.stream.Collectors; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @@ -397,8 +396,7 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests { try (JarFile jar = new JarFile(repackaged)) { List unreproducibleEntries = jar.stream() .filter((entry) -> entry.getLastModifiedTime().toMillis() != 1584352800000L) - .map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime()) - .collect(Collectors.toList()); + .map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime()).toList(); assertThat(unreproducibleEntries).isEmpty(); jarHash.set(FileUtils.sha1Hash(repackaged)); FileSystemUtils.deleteRecursively(project); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java index 4880016f3d..d76257a52d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.jar.JarFile; -import java.util.stream.Collectors; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @@ -99,8 +98,7 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests { try (JarFile jar = new JarFile(repackaged)) { List unreproducibleEntries = jar.stream() .filter((entry) -> entry.getLastModifiedTime().toMillis() != 1584352800000L) - .map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime()) - .collect(Collectors.toList()); + .map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime()).toList(); assertThat(unreproducibleEntries).isEmpty(); warHash.set(FileUtils.sha1Hash(repackaged)); FileSystemUtils.deleteRecursively(project); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java index 93d5e0b01d..14be4fdc2d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java @@ -95,7 +95,7 @@ class CustomLayersProvider { if (layerOrder == null) { return Collections.emptyList(); } - return getChildNodeTextContent(layerOrder, "layer").stream().map(Layer::new).collect(Collectors.toList()); + return getChildNodeTextContent(layerOrder, "layer").stream().map(Layer::new).toList(); } private List> getSelectors(Element root, String elementName, @@ -130,14 +130,14 @@ class CustomLayersProvider { List excludes = getChildNodeTextContent(element, "exclude"); Element includeModuleDependencies = getChildElement(element, "includeModuleDependencies"); Element excludeModuleDependencies = getChildElement(element, "excludeModuleDependencies"); - List> includeFilters = includes.stream().map(filterFactory).collect(Collectors.toList()); + List> includeFilters = includes.stream().map(filterFactory) + .collect(Collectors.toCollection(ArrayList::new)); if (includeModuleDependencies != null) { - includeFilters = new ArrayList<>(includeFilters); includeFilters.add(Library::isLocal); } - List> excludeFilters = excludes.stream().map(filterFactory).collect(Collectors.toList()); + List> excludeFilters = excludes.stream().map(filterFactory) + .collect(Collectors.toCollection(ArrayList::new)); if (excludeModuleDependencies != null) { - excludeFilters = new ArrayList<>(excludeFilters); excludeFilters.add(Library::isLocal); } return new IncludeExcludeContentSelector<>(layer, includeFilters, excludeFilters); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java index 634989c357..36b8b87c7f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,6 @@ package org.springframework.boot.maven; import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; @@ -207,15 +206,14 @@ public class Image { request = request.withPublish(this.publish); } if (!CollectionUtils.isEmpty(this.buildpacks)) { - request = request - .withBuildpacks(this.buildpacks.stream().map(BuildpackReference::of).collect(Collectors.toList())); + request = request.withBuildpacks(this.buildpacks.stream().map(BuildpackReference::of).toList()); } if (!CollectionUtils.isEmpty(this.bindings)) { - request = request.withBindings(this.bindings.stream().map(Binding::of).collect(Collectors.toList())); + request = request.withBindings(this.bindings.stream().map(Binding::of).toList()); } request = request.withNetwork(this.network); if (!CollectionUtils.isEmpty(this.tags)) { - request = request.withTags(this.tags.stream().map(ImageReference::of).collect(Collectors.toList())); + request = request.withTags(this.tags.stream().map(ImageReference::of).toList()); } if (this.buildCache != null) { request = request.withBuildCache(this.buildCache.asCache()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java b/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java index d420fa2ddb..1bc79db0aa 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -116,12 +116,11 @@ class PropertiesMigrationReport { } List getRenamed() { - return this.properties.stream().filter(PropertyMigration::isCompatibleType).collect(Collectors.toList()); + return this.properties.stream().filter(PropertyMigration::isCompatibleType).toList(); } List getUnsupported() { - return this.properties.stream().filter((property) -> !property.isCompatibleType()) - .collect(Collectors.toList()); + return this.properties.stream().filter((property) -> !property.isCompatibleType()).toList(); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 59d2226e56..efca9ececa 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -30,7 +30,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Properties; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.commons.logging.Log; @@ -652,7 +651,7 @@ public class SpringApplication { } private List quoteProfiles(String[] profiles) { - return Arrays.stream(profiles).map((profile) -> "\"" + profile + "\"").collect(Collectors.toList()); + return Arrays.stream(profiles).map((profile) -> "\"" + profile + "\"").toList(); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributors.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributors.java index 480adbd7e7..7085d0c977 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributors.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributors.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.apache.commons.logging.Log; @@ -130,7 +129,7 @@ class ConfigDataEnvironmentContributors implements Iterable list = ((List) result).stream().filter(Objects::nonNull).collect(Collectors.toList()); + List list = ((List) result).stream().filter(Objects::nonNull) + .collect(Collectors.toCollection(ArrayList::new)); for (int i = 0; i < list.size(); i++) { Object element = list.get(i); if (element instanceof ConfigDataLocation location) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java index e8a208ac56..f046e19b18 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java @@ -19,7 +19,6 @@ package org.springframework.boot.context.properties; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.springframework.beans.BeansException; import org.springframework.beans.PropertyEditorRegistry; @@ -159,7 +158,7 @@ class ConfigurationPropertiesBinder { private List getBindHandlerAdvisors() { return this.applicationContext.getBeanProvider(ConfigurationPropertiesBindHandlerAdvisor.class).orderedStream() - .collect(Collectors.toList()); + .toList(); } private Binder getBinder() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java index 8f7e969ba6..af14ea0de8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java @@ -17,7 +17,6 @@ package org.springframework.boot.diagnostics; import java.util.List; -import java.util.stream.Collectors; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -73,8 +72,8 @@ final class FailureAnalyzers implements SpringBootExceptionReporter { .filter((analyzer) -> analyzer instanceof BeanFactoryAware || analyzer instanceof EnvironmentAware) .toList(); if (!awareAnalyzers.isEmpty()) { - String awareAnalyzerNames = StringUtils.collectionToCommaDelimitedString(awareAnalyzers.stream() - .map((analyzer) -> analyzer.getClass().getName()).collect(Collectors.toList())); + String awareAnalyzerNames = StringUtils.collectionToCommaDelimitedString( + awareAnalyzers.stream().map((analyzer) -> analyzer.getClass().getName()).toList()); logger.warn(LogMessage.format( "FailureAnalyzers [%s] implement BeanFactoryAware or EnvironmentAware. " + "Support for these interfaces on FailureAnalyzers is deprecated, " @@ -83,8 +82,7 @@ final class FailureAnalyzers implements SpringBootExceptionReporter { awareAnalyzerNames)); if (context == null) { logger.trace(LogMessage.format("Skipping [%s] due to missing context", awareAnalyzerNames)); - return analyzers.stream().filter((analyzer) -> !awareAnalyzers.contains(analyzer)) - .collect(Collectors.toList()); + return analyzers.stream().filter((analyzer) -> !awareAnalyzers.contains(analyzer)).toList(); } awareAnalyzers.forEach((analyzer) -> { if (analyzer instanceof BeanFactoryAware beanFactoryAware) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java index 7f1cff0090..af546dd1a9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java @@ -17,7 +17,6 @@ package org.springframework.boot.diagnostics.analyzer; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; @@ -63,7 +62,7 @@ class InvalidConfigurationPropertyValueFailureAnalyzer private List getDescriptors(String propertyName) { return getPropertySources().filter((source) -> source.containsProperty(propertyName)) - .map((source) -> Descriptor.get(source, propertyName)).collect(Collectors.toList()); + .map((source) -> Descriptor.get(source, propertyName)).toList(); } private Stream> getPropertySources() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java index 56bac16c92..24eb421b76 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; @@ -71,7 +70,7 @@ class MutuallyExclusiveConfigurationPropertiesFailureAnalyzer private List getDescriptors(String propertyName) { return getPropertySources().filter((source) -> source.containsProperty(propertyName)) - .map((source) -> Descriptor.get(source, propertyName)).collect(Collectors.toList()); + .map((source) -> Descriptor.get(source, propertyName)).toList(); } private Stream> getPropertySources() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java index ecf9964694..a80b63d0df 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.LoaderOptions; @@ -120,7 +119,7 @@ class OriginTrackedYamlLoader extends YamlProcessor { } private void replaceMappingNodeKeys(MappingNode node) { - node.setValue(node.getValue().stream().map(KeyScalarNode::get).collect(Collectors.toList())); + node.setValue(node.getValue().stream().map(KeyScalarNode::get).toList()); } private Object constructTrackedObject(Node node, Object value) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java index c365ffd20e..d4bec28fb6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.Set; import java.util.logging.ConsoleHandler; import java.util.logging.Handler; -import java.util.stream.Collectors; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; @@ -299,8 +298,7 @@ public class Log4J2LoggingSystem extends AbstractLoggingSystem { } private CompositeConfiguration createComposite(List configurations) { - return new CompositeConfiguration( - configurations.stream().map(AbstractConfiguration.class::cast).collect(Collectors.toList())); + return new CompositeConfiguration(configurations.stream().map(AbstractConfiguration.class::cast).toList()); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java index a6d2ca1bfe..8d7964176f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/Instantiator.java @@ -17,6 +17,7 @@ package org.springframework.boot.util; import java.lang.reflect.Constructor; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -137,7 +138,7 @@ public class Instantiator { } private List instantiate(Stream typeSuppliers) { - List instances = typeSuppliers.map(this::instantiate).collect(Collectors.toList()); + List instances = typeSuppliers.map(this::instantiate).collect(Collectors.toCollection(ArrayList::new)); AnnotationAwareOrderComparator.sort(instances); return Collections.unmodifiableList(instances); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/validation/beanvalidation/FilteredMethodValidationPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/validation/beanvalidation/FilteredMethodValidationPostProcessor.java index 45eb34799f..5ff5c17715 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/validation/beanvalidation/FilteredMethodValidationPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/validation/beanvalidation/FilteredMethodValidationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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.boot.validation.beanvalidation; import java.util.ArrayList; import java.util.Collection; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.aop.ClassFilter; @@ -45,7 +44,7 @@ public class FilteredMethodValidationPostProcessor extends MethodValidationPostP * @param excludeFilters filters to apply */ public FilteredMethodValidationPostProcessor(Stream excludeFilters) { - this.excludeFilters = excludeFilters.collect(Collectors.toList()); + this.excludeFilters = excludeFilters.map(MethodValidationExcludeFilter.class::cast).toList(); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java index 667276423f..143f04bfa3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/CompressionCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,6 @@ package org.springframework.boot.web.embedded.netty; import java.util.Arrays; import java.util.List; import java.util.function.BiPredicate; -import java.util.stream.Collectors; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpHeaders; @@ -67,8 +66,7 @@ final class CompressionCustomizer implements NettyServerCustomizer { if (ObjectUtils.isEmpty(mimeTypeValues)) { return ALWAYS_COMPRESS; } - List mimeTypes = Arrays.stream(mimeTypeValues).map(MimeTypeUtils::parseMimeType) - .collect(Collectors.toList()); + List mimeTypes = Arrays.stream(mimeTypeValues).map(MimeTypeUtils::parseMimeType).toList(); return (request, response) -> { String contentType = response.responseHeaders().get(HttpHeaderNames.CONTENT_TYPE); if (!StringUtils.hasLength(contentType)) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java index 04e44a0952..5cbb6640b6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java @@ -84,10 +84,8 @@ public class ServletContextInitializerBeans extends AbstractCollection sortedInitializers = this.initializers.values().stream() - .flatMap((value) -> value.stream().sorted(AnnotationAwareOrderComparator.INSTANCE)) - .collect(Collectors.toList()); - this.sortedList = Collections.unmodifiableList(sortedInitializers); + this.sortedList = this.initializers.values().stream() + .flatMap((value) -> value.stream().sorted(AnnotationAwareOrderComparator.INSTANCE)).toList(); logMappings(this.initializers); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentTests.java index ef72894714..dd452ac329 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentTests.java @@ -22,7 +22,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Supplier; -import java.util.stream.Collectors; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -155,7 +154,7 @@ class ConfigDataEnvironmentTests { ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext, this.environment, this.resourceLoader, this.additionalProfiles, null); configDataEnvironment.processAndApply(); - List> sources = this.environment.getPropertySources().stream().collect(Collectors.toList()); + List> sources = this.environment.getPropertySources().stream().toList(); assertThat(sources.get(sources.size() - 1)).isSameAs(defaultPropertySource); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java index 34238bf53d..1c9c2f4da4 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -23,7 +23,6 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -279,7 +278,7 @@ class CollectionBinderTests { Bindable> target = Bindable.listOf(JavaBean.class); List result = this.binder.bind("foo", target).get(); assertThat(result).hasSize(3); - List values = result.stream().map(JavaBean::getValue).collect(Collectors.toList()); + List values = result.stream().map(JavaBean::getValue).toList(); assertThat(values).containsExactly("a", "b", "c"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java index f4f0d9afb9..fc41f4d91c 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java @@ -364,7 +364,7 @@ class MapBinderTests { source.put("foo.bar[2].value", "c"); this.sources.add(source); Map> map = this.binder.bind("foo", target).get(); - List values = map.get("bar").stream().map(JavaBean::getValue).collect(Collectors.toList()); + List values = map.get("bar").stream().map(JavaBean::getValue).toList(); assertThat(values).containsExactly("a", "b", "c"); } @@ -429,7 +429,7 @@ class MapBinderTests { mockSource.put("foo.bar.baz[2].value", "c"); this.sources.add(mockSource); Map> map = this.binder.bind("foo", target).get(); - List values = map.get("bar.baz").stream().map(JavaBean::getValue).collect(Collectors.toList()); + List values = map.get("bar.baz").stream().map(JavaBean::getValue).toList(); assertThat(values).containsExactly("a", "b", "c"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java index 11ca1d56b3..0427aa6f05 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java @@ -19,7 +19,6 @@ package org.springframework.boot.context.properties.source; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -581,8 +580,8 @@ class ConfigurationPropertyNameTests { names.add(ConfigurationPropertyName.of("foo.baz")); names.add(ConfigurationPropertyName.of("foo")); Collections.sort(names); - assertThat(names.stream().map(ConfigurationPropertyName::toString).collect(Collectors.toList())) - .containsExactly("foo", "foo[2]", "foo[10]", "foo.bar", "foo.bard", "foo.baz"); + assertThat(names.stream().map(ConfigurationPropertyName::toString).toList()).containsExactly("foo", "foo[2]", + "foo[10]", "foo.bar", "foo.bard", "foo.baz"); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java index ba6f4f6e5c..a9229e0839 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java @@ -20,7 +20,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -148,7 +147,7 @@ class BeanCurrentlyInCreationFailureAnalyzerTests { private List readDescriptionLines(FailureAnalysis analysis) throws IOException { try (BufferedReader reader = new BufferedReader(new StringReader(analysis.getDescription()))) { - return reader.lines().collect(Collectors.toList()); + return reader.lines().toList(); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java index b6a1430e3d..da68e5fe34 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java @@ -19,7 +19,6 @@ package org.springframework.boot.jackson; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.ObjectMapper; @@ -90,8 +89,7 @@ class JsonMixinModuleTests { private void load(Class... basePackageClasses) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - List basePackages = Arrays.stream(basePackageClasses).map(ClassUtils::getPackageName) - .collect(Collectors.toList()); + List basePackages = Arrays.stream(basePackageClasses).map(ClassUtils::getPackageName).toList(); context.registerBean(JsonMixinModule.class, () -> new JsonMixinModule(context, basePackages)); context.refresh(); this.context = context; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java index 4d0a296963..5bd5b48ec5 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurerTests.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -311,11 +310,10 @@ class DatabaseInitializationDependencyConfigurerTests { return super.findResources(name); } Properties properties = new Properties(); - properties.put(DatabaseInitializerDetector.class.getName(), String.join(",", - this.databaseInitializerDetectors.stream().map(Class::getName).collect(Collectors.toList()))); - properties.put(DependsOnDatabaseInitializationDetector.class.getName(), - String.join(",", this.dependsOnDatabaseInitializationDetectors.stream().map(Class::getName) - .collect(Collectors.toList()))); + properties.put(DatabaseInitializerDetector.class.getName(), + String.join(",", this.databaseInitializerDetectors.stream().map(Class::getName).toList())); + properties.put(DependsOnDatabaseInitializationDetector.class.getName(), String.join(",", + this.dependsOnDatabaseInitializationDetectors.stream().map(Class::getName).toList())); File springFactories = new File(this.temp, "spring.factories"); try (FileWriter writer = new FileWriter(springFactories)) { properties.store(writer, ""); diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java index e88d247e78..517d8f7dd7 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarDevelopmentIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.io.IOException; import java.io.StringReader; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.condition.DisabledOnOs; @@ -85,7 +84,7 @@ class EmbeddedServletContainerWarDevelopmentIntegrationTests { return Collections.emptyList(); } try (BufferedReader reader = new BufferedReader(new StringReader(input))) { - return reader.lines().collect(Collectors.toList()); + return reader.lines().toList(); } catch (IOException ex) { throw new RuntimeException("Failed to read lines from input '" + input + "'"); diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java index 5ec90ffd94..7bf71616c7 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +21,6 @@ import java.io.IOException; import java.io.StringReader; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.condition.DisabledOnOs; @@ -114,7 +113,7 @@ class EmbeddedServletContainerWarPackagingIntegrationTests { return Collections.emptyList(); } try (BufferedReader reader = new BufferedReader(new StringReader(input))) { - return reader.lines().collect(Collectors.toList()); + return reader.lines().toList(); } catch (IOException ex) { throw new RuntimeException("Failed to read lines from input '" + input + "'");