Use Stream.toList instead of Stream.collect when possible

Update code to make use of `Stream.toList()` whenever possible.

Closes gh-28177
This commit is contained in:
Phillip Webb 2022-10-04 00:26:51 -07:00
parent 118836d204
commit e0b67889a8
159 changed files with 349 additions and 607 deletions

View File

@ -29,7 +29,6 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
import org.gradle.api.Task; import org.gradle.api.Task;
@ -124,8 +123,7 @@ public class AutoConfigurationMetadata extends DefaultTask {
return Collections.emptyList(); return Collections.emptyList();
} }
try (BufferedReader reader = new BufferedReader(new FileReader(file))) { try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
return reader.lines().map(this::stripComment).filter((line) -> !line.isEmpty()) return reader.lines().map(this::stripComment).filter((line) -> !line.isEmpty()).toList();
.collect(Collectors.toList());
} }
} }

View File

@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -301,7 +300,7 @@ public class BomExtension {
public void setModules(List<Object> modules) { public void setModules(List<Object> modules) {
this.modules = modules.stream() this.modules = modules.stream()
.map((input) -> (input instanceof Module module) ? module : new Module((String) input)) .map((input) -> (input instanceof Module module) ? module : new Module((String) input))
.collect(Collectors.toList()); .toList();
} }
public void setImports(List<String> imports) { public void setImports(List<String> imports) {

View File

@ -269,9 +269,7 @@ public class BomPlugin implements Plugin<Project> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<Node> findChildren(Node parent, String name) { private List<Node> findChildren(Node parent, String name) {
return (List<Node>) parent.children().stream().filter((child) -> isNodeWithName(child, name)) return parent.children().stream().filter((child) -> isNodeWithName(child, name)).toList();
.collect(Collectors.toList());
} }
private boolean isNodeWithName(Object candidate, String name) { private boolean isNodeWithName(Object candidate, String name) {

View File

@ -27,7 +27,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.stream.Collectors; import java.util.stream.Stream;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.gradle.api.InvalidUserDataException; import org.gradle.api.InvalidUserDataException;
@ -71,8 +71,7 @@ public final class InteractiveUpgradeResolver implements UpgradeResolver {
librariesByName.put(library.getName(), library); librariesByName.put(library.getName(), library);
} }
return librariesToUpgrade.stream().filter((library) -> !library.getName().equals("Spring Boot")) return librariesToUpgrade.stream().filter((library) -> !library.getName().equals("Spring Boot"))
.map((library) -> resolveUpgrade(library, librariesByName)).filter(Objects::nonNull) .map((library) -> resolveUpgrade(library, librariesByName)).filter(Objects::nonNull).toList();
.collect(Collectors.toList());
} }
private Upgrade resolveUpgrade(Library library, Map<String, Library> libraries) { private Upgrade resolveUpgrade(Library library, Map<String, Library> libraries) {
@ -112,13 +111,13 @@ public final class InteractiveUpgradeResolver implements UpgradeResolver {
} }
List<DependencyVersion> allVersions = moduleVersions.values().stream().flatMap(SortedSet::stream).distinct() List<DependencyVersion> allVersions = moduleVersions.values().stream().flatMap(SortedSet::stream).distinct()
.filter((dependencyVersion) -> isPermitted(dependencyVersion, library.getProhibitedVersions())) .filter((dependencyVersion) -> isPermitted(dependencyVersion, library.getProhibitedVersions()))
.collect(Collectors.toList()); .toList();
if (allVersions.isEmpty()) { if (allVersions.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
return allVersions.stream() Stream<VersionOption> resolvedVersionOptions = allVersions.stream()
.map((version) -> new ResolvedVersionOption(version, getMissingModules(moduleVersions, version))) .map((version) -> new ResolvedVersionOption(version, getMissingModules(moduleVersions, version)));
.collect(Collectors.toList()); return resolvedVersionOptions.toList();
} }
private List<VersionOption> determineAlignedVersionOption(Library library, Map<String, Library> libraries) { private List<VersionOption> determineAlignedVersionOption(Library library, Map<String, Library> libraries) {

View File

@ -30,7 +30,6 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
@ -163,7 +162,7 @@ public class UpgradeBom extends DefaultTask {
} }
Predicate<String> libraryPredicate = Pattern.compile(pattern).asPredicate(); Predicate<String> libraryPredicate = Pattern.compile(pattern).asPredicate();
List<Library> matchingLibraries = this.bom.getLibraries().stream() List<Library> matchingLibraries = this.bom.getLibraries().stream()
.filter((library) -> libraryPredicate.test(library.getName())).collect(Collectors.toList()); .filter((library) -> libraryPredicate.test(library.getName())).toList();
if (matchingLibraries.isEmpty()) { if (matchingLibraries.isEmpty()) {
throw new InvalidUserDataException("No libraries matched '" + pattern + "'"); throw new InvalidUserDataException("No libraries matched '" + pattern + "'");
} }

View File

@ -20,7 +20,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException.Forbidden; import org.springframework.web.client.HttpClientErrorException.Forbidden;
@ -92,8 +91,7 @@ final class StandardGitHubRepository implements GitHubRepository {
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
private <T> List<T> get(String name, Function<Map<String, Object>, T> mapper) { private <T> List<T> get(String name, Function<Map<String, Object>, T> mapper) {
ResponseEntity<List> response = this.rest.getForEntity(name, List.class); ResponseEntity<List> response = this.rest.getForEntity(name, List.class);
List<Map<String, Object>> body = response.getBody(); return ((List<Map<String, Object>>) response.getBody()).stream().map(mapper).toList();
return body.stream().map(mapper).collect(Collectors.toList());
} }
} }

View File

@ -106,8 +106,7 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask {
if (!exclusions.isEmpty()) { if (!exclusions.isEmpty()) {
Dependency toCheck = this.dependencyById.get(dependencyId); Dependency toCheck = this.dependencyById.get(dependencyId);
List<String> dependencies = this.configurations.detachedConfiguration(toCheck, this.platform) List<String> dependencies = this.configurations.detachedConfiguration(toCheck, this.platform)
.getIncoming().getArtifacts().getArtifacts().stream().map(this::getId) .getIncoming().getArtifacts().getArtifacts().stream().map(this::getId).toList();
.collect(Collectors.toList());
exclusions.removeAll(dependencies); exclusions.removeAll(dependencies);
removeProfileExclusions(dependencyId, exclusions); removeProfileExclusions(dependencyId, exclusions);
if (!exclusions.isEmpty()) { if (!exclusions.isEmpty()) {

View File

@ -27,7 +27,6 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonMappingException;
@ -95,7 +94,7 @@ public class CheckAdditionalSpringConfigurationMetadata extends SourceTask {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void check(String key, Map<String, Object> json, Analysis analysis) { private void check(String key, Map<String, Object> json, Analysis analysis) {
List<Map<String, Object>> groups = (List<Map<String, Object>>) json.get(key); List<Map<String, Object>> groups = (List<Map<String, Object>>) json.get(key);
List<String> names = groups.stream().map((group) -> (String) group.get("name")).collect(Collectors.toList()); List<String> names = groups.stream().map((group) -> (String) group.get("name")).toList();
List<String> sortedNames = sortedCopy(names); List<String> sortedNames = sortedCopy(names);
for (int i = 0; i < names.size(); i++) { for (int i = 0; i < names.size(); i++) {
String actual = names.get(i); String actual = names.get(i);

View File

@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonMappingException;
@ -154,8 +153,7 @@ public class CheckSpringConfigurationMetadata extends DefaultTask {
else { else {
lines.add("The following properties have no description:"); lines.add("The following properties have no description:");
lines.add(""); lines.add("");
lines.addAll(this.propertiesWithNoDescription.stream().map((line) -> "\t" + line) lines.addAll(this.propertiesWithNoDescription.stream().map((line) -> "\t" + line).toList());
.collect(Collectors.toList()));
} }
lines.add(""); lines.add("");
return lines.iterator(); return lines.iterator();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
import org.gradle.api.Task; 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.printf("`%s:%s:%s`%n", plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion());
writer.println(); writer.println();
writer.println(mojo.getDescription()); writer.println(mojo.getDescription());
List<Parameter> parameters = mojo.getParameters().stream().filter(Parameter::isEditable) List<Parameter> parameters = mojo.getParameters().stream().filter(Parameter::isEditable).toList();
.collect(Collectors.toList()); List<Parameter> requiredParameters = parameters.stream().filter(Parameter::isRequired).toList();
List<Parameter> requiredParameters = parameters.stream().filter(Parameter::isRequired)
.collect(Collectors.toList());
String parametersSectionId = sectionId + "-parameters"; String parametersSectionId = sectionId + "-parameters";
String detailsSectionId = parametersSectionId + "-details"; String detailsSectionId = parametersSectionId + "-details";
if (!requiredParameters.isEmpty()) { if (!requiredParameters.isEmpty()) {
@ -112,7 +109,7 @@ public class DocumentPluginGoals extends DefaultTask {
writeParametersTable(writer, detailsSectionId, requiredParameters); writeParametersTable(writer, detailsSectionId, requiredParameters);
} }
List<Parameter> optionalParameters = parameters.stream().filter((parameter) -> !parameter.isRequired()) List<Parameter> optionalParameters = parameters.stream().filter((parameter) -> !parameter.isRequired())
.collect(Collectors.toList()); .toList();
if (!optionalParameters.isEmpty()) { if (!optionalParameters.isEmpty()) {
writer.println(); writer.println();
writer.println(); writer.println();

View File

@ -19,7 +19,6 @@ package org.springframework.boot.build.testing;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.stream.Collectors;
import org.gradle.api.services.BuildService; import org.gradle.api.services.BuildService;
import org.gradle.api.services.BuildServiceParameters; import org.gradle.api.services.BuildServiceParameters;
@ -42,8 +41,7 @@ public abstract class TestResultsOverview
private final Object monitor = new Object(); private final Object monitor = new Object();
void addFailures(Test test, List<TestDescriptor> failureDescriptors) { void addFailures(Test test, List<TestDescriptor> failureDescriptors) {
List<TestFailure> testFailures = failureDescriptors.stream().map(TestFailure::new).sorted() List<TestFailure> testFailures = failureDescriptors.stream().map(TestFailure::new).sorted().toList();
.collect(Collectors.toList());
synchronized (this.monitor) { synchronized (this.monitor) {
this.testFailures.put(test, testFailures); this.testFailures.put(test, testFailures);
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -44,8 +43,8 @@ class PluginXmlParserTests {
assertThat(plugin.getArtifactId()).isEqualTo("spring-boot-maven-plugin"); assertThat(plugin.getArtifactId()).isEqualTo("spring-boot-maven-plugin");
assertThat(plugin.getVersion()).isEqualTo("2.2.0.GRADLE-SNAPSHOT"); assertThat(plugin.getVersion()).isEqualTo("2.2.0.GRADLE-SNAPSHOT");
assertThat(plugin.getGoalPrefix()).isEqualTo("spring-boot"); assertThat(plugin.getGoalPrefix()).isEqualTo("spring-boot");
assertThat(plugin.getMojos().stream().map(PluginXmlParser.Mojo::getGoal).collect(Collectors.toList())) assertThat(plugin.getMojos().stream().map(PluginXmlParser.Mojo::getGoal)).containsExactly("build-info", "help",
.containsExactly("build-info", "help", "repackage", "run", "start", "stop"); "repackage", "run", "start", "stop");
} }
@Test @Test

View File

@ -24,7 +24,6 @@ import java.io.PrintWriter;
import java.io.StringReader; import java.io.StringReader;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner; import org.gradle.testkit.runner.GradleRunner;
@ -170,7 +169,7 @@ class TestFailuresPluginIntegrationTests {
private List<String> readLines(String output) { private List<String> readLines(String output) {
try (BufferedReader reader = new BufferedReader(new StringReader(output))) { try (BufferedReader reader = new BufferedReader(new StringReader(output))) {
return reader.lines().collect(Collectors.toList()); return reader.lines().toList();
} }
catch (IOException ex) { catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);

View File

@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
@ -99,7 +98,7 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
List<InfoContributor> contributors = infoContributors.orderedStream() List<InfoContributor> contributors = infoContributors.orderedStream()
.map((infoContributor) -> (infoContributor instanceof GitInfoContributor) .map((infoContributor) -> (infoContributor instanceof GitInfoContributor)
? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor) ? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor)
.collect(Collectors.toList()); .toList();
return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors)); return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors));
} }

View File

@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer; import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer;
@ -103,7 +102,7 @@ public class CloudFoundryActuatorAutoConfiguration {
List<InfoContributor> contributors = infoContributors.orderedStream() List<InfoContributor> contributors = infoContributors.orderedStream()
.map((infoContributor) -> (infoContributor instanceof GitInfoContributor) .map((infoContributor) -> (infoContributor instanceof GitInfoContributor)
? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor) ? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor)
.collect(Collectors.toList()); .toList();
return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors)); return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors));
} }

View File

@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.endpoint; package org.springframework.boot.actuate.autoconfigure.endpoint;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
@ -52,9 +51,8 @@ public class EndpointAutoConfiguration {
public ParameterValueMapper endpointOperationParameterMapper( public ParameterValueMapper endpointOperationParameterMapper(
@EndpointConverter ObjectProvider<Converter<?, ?>> converters, @EndpointConverter ObjectProvider<Converter<?, ?>> converters,
@EndpointConverter ObjectProvider<GenericConverter> genericConverters) { @EndpointConverter ObjectProvider<GenericConverter> genericConverters) {
ConversionService conversionService = createConversionService( ConversionService conversionService = createConversionService(converters.orderedStream().toList(),
converters.orderedStream().collect(Collectors.toList()), genericConverters.orderedStream().toList());
genericConverters.orderedStream().collect(Collectors.toList()));
return new ConversionServiceParameterValueMapper(conversionService); return new ConversionServiceParameterValueMapper(conversionService);
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.jmx; package org.springframework.boot.actuate.autoconfigure.endpoint.jmx;
import java.util.stream.Collectors;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -84,8 +82,7 @@ public class JmxEndpointAutoConfiguration {
ObjectProvider<OperationInvokerAdvisor> invokerAdvisors, ObjectProvider<OperationInvokerAdvisor> invokerAdvisors,
ObjectProvider<EndpointFilter<ExposableJmxEndpoint>> filters) { ObjectProvider<EndpointFilter<ExposableJmxEndpoint>> filters) {
return new JmxEndpointDiscoverer(this.applicationContext, parameterValueMapper, return new JmxEndpointDiscoverer(this.applicationContext, parameterValueMapper,
invokerAdvisors.orderedStream().collect(Collectors.toList()), invokerAdvisors.orderedStream().toList(), filters.orderedStream().toList());
filters.orderedStream().collect(Collectors.toList()));
} }
@Bean @Bean

View File

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
@ -91,17 +90,15 @@ public class WebEndpointAutoConfiguration {
ObjectProvider<OperationInvokerAdvisor> invokerAdvisors, ObjectProvider<OperationInvokerAdvisor> invokerAdvisors,
ObjectProvider<EndpointFilter<ExposableWebEndpoint>> filters) { ObjectProvider<EndpointFilter<ExposableWebEndpoint>> filters) {
return new WebEndpointDiscoverer(this.applicationContext, parameterValueMapper, endpointMediaTypes, return new WebEndpointDiscoverer(this.applicationContext, parameterValueMapper, endpointMediaTypes,
endpointPathMappers.orderedStream().collect(Collectors.toList()), endpointPathMappers.orderedStream().toList(), invokerAdvisors.orderedStream().toList(),
invokerAdvisors.orderedStream().collect(Collectors.toList()), filters.orderedStream().toList());
filters.orderedStream().collect(Collectors.toList()));
} }
@Bean @Bean
@ConditionalOnMissingBean(ControllerEndpointsSupplier.class) @ConditionalOnMissingBean(ControllerEndpointsSupplier.class)
public ControllerEndpointDiscoverer controllerEndpointDiscoverer(ObjectProvider<PathMapper> endpointPathMappers, public ControllerEndpointDiscoverer controllerEndpointDiscoverer(ObjectProvider<PathMapper> endpointPathMappers,
ObjectProvider<Collection<EndpointFilter<ExposableControllerEndpoint>>> filters) { ObjectProvider<Collection<EndpointFilter<ExposableControllerEndpoint>>> filters) {
return new ControllerEndpointDiscoverer(this.applicationContext, return new ControllerEndpointDiscoverer(this.applicationContext, endpointPathMappers.orderedStream().toList(),
endpointPathMappers.orderedStream().collect(Collectors.toList()),
filters.getIfAvailable(Collections::emptyList)); filters.getIfAvailable(Collections::emptyList));
} }
@ -134,9 +131,8 @@ public class WebEndpointAutoConfiguration {
ServletEndpointDiscoverer servletEndpointDiscoverer(ApplicationContext applicationContext, ServletEndpointDiscoverer servletEndpointDiscoverer(ApplicationContext applicationContext,
ObjectProvider<PathMapper> endpointPathMappers, ObjectProvider<PathMapper> endpointPathMappers,
ObjectProvider<EndpointFilter<ExposableServletEndpoint>> filters) { ObjectProvider<EndpointFilter<ExposableServletEndpoint>> filters) {
return new ServletEndpointDiscoverer(applicationContext, return new ServletEndpointDiscoverer(applicationContext, endpointPathMappers.orderedStream().toList(),
endpointPathMappers.orderedStream().collect(Collectors.toList()), filters.orderedStream().toList());
filters.orderedStream().collect(Collectors.toList()));
} }
} }

View File

@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.server.model.Resource;
@ -183,7 +182,7 @@ class JerseyWebEndpointManagementContextConfiguration {
WebServerNamespace.MANAGEMENT, this.groups); WebServerNamespace.MANAGEMENT, this.groups);
Collection<Resource> endpointResources = resourceFactory Collection<Resource> endpointResources = resourceFactory
.createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false) .createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false)
.stream().filter(Objects::nonNull).collect(Collectors.toList()); .stream().filter(Objects::nonNull).toList();
register(endpointResources, config); register(endpointResources, config);
} }

View File

@ -20,7 +20,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.server.model.Resource;
@ -162,7 +161,7 @@ class HealthEndpointWebExtensionConfiguration {
WebServerNamespace.SERVER, this.groups); WebServerNamespace.SERVER, this.groups);
Collection<Resource> endpointResources = resourceFactory Collection<Resource> endpointResources = resourceFactory
.createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false) .createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false)
.stream().filter(Objects::nonNull).collect(Collectors.toList()); .stream().filter(Objects::nonNull).toList();
register(endpointResources, config); register(endpointResources, config);
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.info; package org.springframework.boot.actuate.autoconfigure.info;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.actuate.info.InfoContributor; import org.springframework.boot.actuate.info.InfoContributor;
@ -40,7 +38,7 @@ public class InfoEndpointAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public InfoEndpoint infoEndpoint(ObjectProvider<InfoContributor> infoContributors) { public InfoEndpoint infoEndpoint(ObjectProvider<InfoContributor> infoContributors) {
return new InfoEndpoint(infoContributors.orderedStream().collect(Collectors.toList())); return new InfoEndpoint(infoContributors.orderedStream().toList());
} }
} }

View File

@ -73,7 +73,7 @@ public class DataSourceHealthContributorAutoConfiguration implements Initializin
public DataSourceHealthContributorAutoConfiguration( public DataSourceHealthContributorAutoConfiguration(
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) { ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
this.metadataProviders = metadataProviders.orderedStream().collect(Collectors.toList()); this.metadataProviders = metadataProviders.orderedStream().toList();
} }
@Override @Override

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; 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.MeterRegistry;
import io.micrometer.core.instrument.Metrics; import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.binder.MeterBinder; import io.micrometer.core.instrument.binder.MeterBinder;
@ -74,7 +71,7 @@ class MeterRegistryConfigurer {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void customize(MeterRegistry registry) { 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)); .withLogger(MeterRegistryConfigurer.class).invoke((customizer) -> customizer.customize(registry));
} }
@ -86,8 +83,4 @@ class MeterRegistryConfigurer {
this.binders.orderedStream().forEach((binder) -> binder.bindTo(registry)); this.binders.orderedStream().forEach((binder) -> binder.bindTo(registry));
} }
private <T> List<T> asOrderedList(ObjectProvider<T> provider) {
return provider.orderedStream().collect(Collectors.toList());
}
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Arrays;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Meter.Id; import io.micrometer.core.instrument.Meter.Id;
@ -61,11 +61,14 @@ public class PropertiesMeterFilter implements MeterFilter {
return new MeterFilter() { return new MeterFilter() {
}; };
} }
Tags commonTags = Tags.of(tags.entrySet().stream().map((entry) -> Tag.of(entry.getKey(), entry.getValue())) Tags commonTags = Tags.of(tags.entrySet().stream().map(PropertiesMeterFilter::asTag).toList());
.collect(Collectors.toList()));
return MeterFilter.commonTags(commonTags); return MeterFilter.commonTags(commonTags);
} }
private static Tag asTag(Entry<String, String> entry) {
return Tag.of(entry.getKey(), entry.getValue());
}
@Override @Override
public MeterFilterReply accept(Meter.Id id) { public MeterFilterReply accept(Meter.Id id) {
boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, true); boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, true);

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.metrics.graphql; package org.springframework.boot.actuate.autoconfigure.metrics.graphql;
import java.util.stream.Collectors;
import graphql.GraphQL; import graphql.GraphQL;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
@ -56,7 +54,7 @@ public class GraphQlMetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(GraphQlTagsProvider.class) @ConditionalOnMissingBean(GraphQlTagsProvider.class)
public DefaultGraphQlTagsProvider graphQlTagsProvider(ObjectProvider<GraphQlTagsContributor> contributors) { public DefaultGraphQlTagsProvider graphQlTagsProvider(ObjectProvider<GraphQlTagsContributor> contributors) {
return new DefaultGraphQlTagsProvider(contributors.orderedStream().collect(Collectors.toList())); return new DefaultGraphQlTagsProvider(contributors.orderedStream().toList());
} }
@Bean @Bean

View File

@ -20,7 +20,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -87,8 +86,7 @@ public class DataSourcePoolMetricsAutoConfiguration {
@Override @Override
public void bindTo(MeterRegistry registry) { public void bindTo(MeterRegistry registry) {
List<DataSourcePoolMetadataProvider> metadataProvidersList = this.metadataProviders.stream() List<DataSourcePoolMetadataProvider> metadataProvidersList = this.metadataProviders.stream().toList();
.collect(Collectors.toList());
this.dataSources.forEach((name, dataSource) -> bindDataSourceToRegistry(name, dataSource, this.dataSources.forEach((name, dataSource) -> bindDataSourceToRegistry(name, dataSource,
metadataProvidersList, registry)); metadataProvidersList, registry));
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.metrics.web.reactive; 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.MeterRegistry;
import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.core.instrument.config.MeterFilter;
@ -64,7 +62,7 @@ public class WebFluxMetricsAutoConfiguration {
@ConditionalOnMissingBean(WebFluxTagsProvider.class) @ConditionalOnMissingBean(WebFluxTagsProvider.class)
public DefaultWebFluxTagsProvider webFluxTagsProvider(ObjectProvider<WebFluxTagsContributor> contributors) { public DefaultWebFluxTagsProvider webFluxTagsProvider(ObjectProvider<WebFluxTagsContributor> contributors) {
return new DefaultWebFluxTagsProvider(this.properties.getWeb().getServer().getRequest().isIgnoreTrailingSlash(), return new DefaultWebFluxTagsProvider(this.properties.getWeb().getServer().getRequest().isIgnoreTrailingSlash(),
contributors.orderedStream().collect(Collectors.toList())); contributors.orderedStream().toList());
} }
@Bean @Bean

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.metrics.web.servlet; 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.MeterRegistry;
import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.core.instrument.config.MeterFilter;
import jakarta.servlet.DispatcherType; import jakarta.servlet.DispatcherType;
@ -76,7 +74,7 @@ public class WebMvcMetricsAutoConfiguration {
@ConditionalOnMissingBean(WebMvcTagsProvider.class) @ConditionalOnMissingBean(WebMvcTagsProvider.class)
public DefaultWebMvcTagsProvider webMvcTagsProvider(ObjectProvider<WebMvcTagsContributor> contributors) { public DefaultWebMvcTagsProvider webMvcTagsProvider(ObjectProvider<WebMvcTagsContributor> contributors) {
return new DefaultWebMvcTagsProvider(this.properties.getWeb().getServer().getRequest().isIgnoreTrailingSlash(), return new DefaultWebMvcTagsProvider(this.properties.getWeb().getServer().getRequest().isIgnoreTrailingSlash(),
contributors.orderedStream().collect(Collectors.toList())); contributors.orderedStream().toList());
} }
@Bean @Bean

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.scheduling; package org.springframework.boot.actuate.autoconfigure.scheduling;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint; import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint;
@ -40,7 +38,7 @@ public class ScheduledTasksEndpointAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ScheduledTasksEndpoint scheduledTasksEndpoint(ObjectProvider<ScheduledTaskHolder> holders) { public ScheduledTasksEndpoint scheduledTasksEndpoint(ObjectProvider<ScheduledTaskHolder> holders) {
return new ScheduledTasksEndpoint(holders.orderedStream().collect(Collectors.toList())); return new ScheduledTasksEndpoint(holders.orderedStream().toList());
} }
} }

View File

@ -246,8 +246,11 @@ public final class EndpointRequest {
} }
private List<ServerWebExchangeMatcher> getDelegateMatchers(Set<String> paths) { private List<ServerWebExchangeMatcher> getDelegateMatchers(Set<String> paths) {
return paths.stream().map((path) -> new PathPatternParserServerWebExchangeMatcher(path + "/**")) return paths.stream().map(this::getDelegateMatcher).collect(Collectors.toCollection(ArrayList::new));
.collect(Collectors.toList()); }
private PathPatternParserServerWebExchangeMatcher getDelegateMatcher(String path) {
return new PathPatternParserServerWebExchangeMatcher(path + "/**");
} }
@Override @Override

View File

@ -270,7 +270,7 @@ public final class EndpointRequest {
private List<RequestMatcher> getDelegateMatchers(RequestMatcherFactory requestMatcherFactory, private List<RequestMatcher> getDelegateMatchers(RequestMatcherFactory requestMatcherFactory,
RequestMatcherProvider matcherProvider, Set<String> paths) { RequestMatcherProvider matcherProvider, Set<String> paths) {
return paths.stream().map((path) -> requestMatcherFactory.antPath(matcherProvider, path, "/**")) return paths.stream().map((path) -> requestMatcherFactory.antPath(matcherProvider, path, "/**"))
.collect(Collectors.toList()); .collect(Collectors.toCollection(ArrayList::new));
} }
} }

View File

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.tracing;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.SamplerFunction;
import io.micrometer.tracing.otel.bridge.DefaultHttpClientAttributesGetter; import io.micrometer.tracing.otel.bridge.DefaultHttpClientAttributesGetter;
@ -110,8 +109,7 @@ public class OpenTelemetryAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
ContextPropagators otelContextPropagators(ObjectProvider<TextMapPropagator> textMapPropagators) { ContextPropagators otelContextPropagators(ObjectProvider<TextMapPropagator> textMapPropagators) {
return ContextPropagators return ContextPropagators.create(TextMapPropagator.composite(textMapPropagators.orderedStream().toList()));
.create(TextMapPropagator.composite(textMapPropagators.orderedStream().collect(Collectors.toList())));
} }
@Bean @Bean
@ -122,8 +120,11 @@ public class OpenTelemetryAutoConfiguration {
@Bean @Bean
SpanProcessor otelSpanProcessor(ObjectProvider<SpanExporter> spanExporters) { SpanProcessor otelSpanProcessor(ObjectProvider<SpanExporter> spanExporters) {
return SpanProcessor.composite(spanExporters.orderedStream() return SpanProcessor.composite(spanExporters.orderedStream().map(this::buildBatchSpanProcessor).toList());
.map((exporter) -> BatchSpanProcessor.builder(exporter).build()).collect(Collectors.toList())); }
private SpanProcessor buildBatchSpanProcessor(SpanExporter exporter) {
return BatchSpanProcessor.builder(exporter).build();
} }
@Bean @Bean

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.web.mappings; package org.springframework.boot.actuate.autoconfigure.web.mappings;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider; import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
@ -51,8 +49,7 @@ public class MappingsEndpointAutoConfiguration {
@Bean @Bean
public MappingsEndpoint mappingsEndpoint(ApplicationContext applicationContext, public MappingsEndpoint mappingsEndpoint(ApplicationContext applicationContext,
ObjectProvider<MappingDescriptionProvider> descriptionProviders) { ObjectProvider<MappingDescriptionProvider> descriptionProviders) {
return new MappingsEndpoint(descriptionProviders.orderedStream().collect(Collectors.toList()), return new MappingsEndpoint(descriptionProviders.orderedStream().toList(), applicationContext);
applicationContext);
} }
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; package org.springframework.boot.actuate.autoconfigure.web.server;
import java.util.Arrays; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
@ -77,21 +75,17 @@ public abstract class ManagementWebServerFactoryCustomizer<T extends Configurabl
} }
private void customizeSameAsParentContext(T factory) { private void customizeSameAsParentContext(T factory) {
List<WebServerFactoryCustomizer<?>> customizers = Arrays.stream(this.customizerClasses).map(this::getCustomizer) List<WebServerFactoryCustomizer<?>> customizers = new ArrayList<>();
.filter(Objects::nonNull).collect(Collectors.toList()); for (Class<? extends WebServerFactoryCustomizer<?>> customizerClass : this.customizerClasses) {
try {
customizers.add(BeanFactoryUtils.beanOfTypeIncludingAncestors(this.beanFactory, customizerClass));
}
catch (NoSuchBeanDefinitionException ex) {
}
}
invokeCustomizers(factory, customizers); invokeCustomizers(factory, customizers);
} }
private WebServerFactoryCustomizer<?> getCustomizer(
Class<? extends WebServerFactoryCustomizer<?>> customizerClass) {
try {
return BeanFactoryUtils.beanOfTypeIncludingAncestors(this.beanFactory, customizerClass);
}
catch (NoSuchBeanDefinitionException ex) {
return null;
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void invokeCustomizers(T factory, List<WebServerFactoryCustomizer<?>> customizers) { private void invokeCustomizers(T factory, List<WebServerFactoryCustomizer<?>> customizers) {
LambdaSafe.callbacks(WebServerFactoryCustomizer.class, customizers, factory) LambdaSafe.callbacks(WebServerFactoryCustomizer.class, customizers, factory)

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
@ -211,8 +210,7 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests {
.run((context) -> { .run((context) -> {
CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context); CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping(context);
Collection<ExposableWebEndpoint> endpoints = handlerMapping.getEndpoints(); Collection<ExposableWebEndpoint> endpoints = handlerMapping.getEndpoints();
List<EndpointId> endpointIds = endpoints.stream().map(ExposableWebEndpoint::getEndpointId) List<EndpointId> endpointIds = endpoints.stream().map(ExposableWebEndpoint::getEndpointId).toList();
.collect(Collectors.toList());
assertThat(endpointIds).contains(EndpointId.of("test")); assertThat(endpointIds).contains(EndpointId.of("test"));
}); });
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -90,8 +89,7 @@ class WebEndpointAutoConfigurationTests {
WebEndpointDiscoverer discoverer = context.getBean(WebEndpointDiscoverer.class); WebEndpointDiscoverer discoverer = context.getBean(WebEndpointDiscoverer.class);
Collection<ExposableWebEndpoint> endpoints = discoverer.getEndpoints(); Collection<ExposableWebEndpoint> endpoints = discoverer.getEndpoints();
ExposableWebEndpoint[] webEndpoints = endpoints.toArray(new ExposableWebEndpoint[0]); ExposableWebEndpoint[] webEndpoints = endpoints.toArray(new ExposableWebEndpoint[0]);
List<String> paths = Arrays.stream(webEndpoints).map(PathMappedEndpoint::getRootPath) List<String> paths = Arrays.stream(webEndpoints).map(PathMappedEndpoint::getRootPath).toList();
.collect(Collectors.toList());
assertThat(paths).containsOnly("1/testone", "foo", "testtwo"); assertThat(paths).containsOnly("1/testone", "foo", "testtwo");
}); });
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.List;
import java.util.Map; import java.util.Map;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -60,8 +59,8 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWit
public abstract class AbstractEndpointDocumentationTests { public abstract class AbstractEndpointDocumentationTests {
protected static String describeEnumValues(Class<? extends Enum<?>> enumType) { protected static String describeEnumValues(Class<? extends Enum<?>> enumType) {
return StringUtils.collectionToDelimitedString(Stream.of(enumType.getEnumConstants()) return StringUtils.collectionToDelimitedString(
.map((constant) -> "`" + constant.name() + "`").collect(Collectors.toList()), ", "); Stream.of(enumType.getEnumConstants()).map((constant) -> "`" + constant.name() + "`").toList(), ", ");
} }
protected OperationPreprocessor limit(String... keys) { protected OperationPreprocessor limit(String... keys) {
@ -112,8 +111,7 @@ public abstract class AbstractEndpointDocumentationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T> List<Object> select(List<Object> candidates, Predicate<T> filter) { private <T> List<Object> select(List<Object> candidates, Predicate<T> filter) {
return candidates.stream().filter((candidate) -> filter.test((T) candidate)).limit(3) return candidates.stream().filter((candidate) -> filter.test((T) candidate)).limit(3).toList();
.collect(Collectors.toList());
} }
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)

View File

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.security.servlet;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -152,7 +151,7 @@ class ManagementWebSecurityAutoConfigurationTests {
SecurityFilterChain testRemoteDevToolsSecurityFilterChain = context SecurityFilterChain testRemoteDevToolsSecurityFilterChain = context
.getBean("testRemoteDevToolsSecurityFilterChain", SecurityFilterChain.class); .getBean("testRemoteDevToolsSecurityFilterChain", SecurityFilterChain.class);
List<SecurityFilterChain> orderedSecurityFilterChains = context.getBeanProvider(SecurityFilterChain.class) List<SecurityFilterChain> orderedSecurityFilterChains = context.getBeanProvider(SecurityFilterChain.class)
.orderedStream().collect(Collectors.toList()); .orderedStream().toList();
assertThat(orderedSecurityFilterChains).containsExactly(testRemoteDevToolsSecurityFilterChain, assertThat(orderedSecurityFilterChains).containsExactly(testRemoteDevToolsSecurityFilterChain,
testSecurityFilterChain); testSecurityFilterChain);
assertThat(context).doesNotHaveBean(ManagementWebSecurityAutoConfiguration.class); assertThat(context).doesNotHaveBean(ManagementWebSecurityAutoConfiguration.class);

View File

@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.web.server;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -83,7 +82,7 @@ class ManagementContextConfigurationImportSelectorTests {
private final List<String> factoryNames; private final List<String> factoryNames;
private TestManagementContextConfigurationsImportSelector(Class<?>... classes) { 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 @Override

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; 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.DeleteOperation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
@ -110,21 +109,19 @@ public class CachesEndpoint {
private List<CacheEntry> getCacheEntries(Predicate<String> cacheNamePredicate, private List<CacheEntry> getCacheEntries(Predicate<String> cacheNamePredicate,
Predicate<String> cacheManagerNamePredicate) { Predicate<String> cacheManagerNamePredicate) {
return this.cacheManagers.keySet().stream().filter(cacheManagerNamePredicate) return this.cacheManagers.keySet().stream().filter(cacheManagerNamePredicate)
.flatMap((cacheManagerName) -> getCacheEntries(cacheManagerName, cacheNamePredicate).stream()) .flatMap((cacheManagerName) -> getCacheEntries(cacheManagerName, cacheNamePredicate).stream()).toList();
.collect(Collectors.toList());
} }
private List<CacheEntry> getCacheEntries(String cacheManagerName, Predicate<String> cacheNamePredicate) { private List<CacheEntry> getCacheEntries(String cacheManagerName, Predicate<String> cacheNamePredicate) {
CacheManager cacheManager = this.cacheManagers.get(cacheManagerName); CacheManager cacheManager = this.cacheManagers.get(cacheManagerName);
return cacheManager.getCacheNames().stream().filter(cacheNamePredicate).map(cacheManager::getCache) return cacheManager.getCacheNames().stream().filter(cacheNamePredicate).map(cacheManager::getCache)
.filter(Objects::nonNull).map((cache) -> new CacheEntry(cache, cacheManagerName)) .filter(Objects::nonNull).map((cache) -> new CacheEntry(cache, cacheManagerName)).toList();
.collect(Collectors.toList());
} }
private CacheEntry extractUniqueCacheEntry(String cache, List<CacheEntry> entries) { private CacheEntry extractUniqueCacheEntry(String cache, List<CacheEntry> entries) {
if (entries.size() > 1) { if (entries.size() > 1) {
throw new NonUniqueCacheException(cache, 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); return (!entries.isEmpty() ? entries.get(0) : null);
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import com.couchbase.client.core.diagnostics.ClusterState; import com.couchbase.client.core.diagnostics.ClusterState;
import com.couchbase.client.core.diagnostics.DiagnosticsResult; import com.couchbase.client.core.diagnostics.DiagnosticsResult;
@ -44,7 +43,7 @@ class CouchbaseHealth {
builder = isCouchbaseUp(this.diagnostics) ? builder.up() : builder.down(); builder = isCouchbaseUp(this.diagnostics) ? builder.up() : builder.down();
builder.withDetail("sdk", this.diagnostics.sdk()); builder.withDetail("sdk", this.diagnostics.sdk());
builder.withDetail("endpoints", this.diagnostics.endpoints().values().stream().flatMap(Collection::stream) 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) { private boolean isCouchbaseUp(DiagnosticsResult diagnostics) {

View File

@ -100,7 +100,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
private DiscoveredOperationsFactory<O> getOperationsFactory(ParameterValueMapper parameterValueMapper, private DiscoveredOperationsFactory<O> getOperationsFactory(ParameterValueMapper parameterValueMapper,
Collection<OperationInvokerAdvisor> invokerAdvisors) { Collection<OperationInvokerAdvisor> invokerAdvisors) {
return new DiscoveredOperationsFactory<O>(parameterValueMapper, invokerAdvisors) { return new DiscoveredOperationsFactory<>(parameterValueMapper, invokerAdvisors) {
@Override @Override
protected O createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, protected O createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod,
@ -199,8 +199,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
addOperations(indexed, id, extensionBean.getBean(), true); addOperations(indexed, id, extensionBean.getBean(), true);
} }
assertNoDuplicateOperations(endpointBean, indexed); assertNoDuplicateOperations(endpointBean, indexed);
List<O> operations = indexed.values().stream().map(this::getLast).filter(Objects::nonNull) List<O> operations = indexed.values().stream().map(this::getLast).filter(Objects::nonNull).toList();
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
return createEndpoint(endpointBean.getBean(), id, endpointBean.isEnabledByDefault(), operations); return createEndpoint(endpointBean.getBean(), id, endpointBean.isEnabledByDefault(), operations);
} }
@ -224,7 +223,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
private void assertNoDuplicateOperations(EndpointBean endpointBean, MultiValueMap<OperationKey, O> indexed) { private void assertNoDuplicateOperations(EndpointBean endpointBean, MultiValueMap<OperationKey, O> indexed) {
List<OperationKey> duplicates = indexed.entrySet().stream().filter((entry) -> entry.getValue().size() > 1) List<OperationKey> 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()) { if (!duplicates.isEmpty()) {
Set<ExtensionBean> extensions = endpointBean.getExtensions(); Set<ExtensionBean> extensions = endpointBean.getExtensions();
String extensionBeanNames = extensions.stream().map(ExtensionBean::getBeanName) String extensionBeanNames = extensions.stream().map(ExtensionBean::getBeanName)

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.stream.Collectors;
import javax.management.InstanceNotFoundException; import javax.management.InstanceNotFoundException;
import javax.management.MBeanRegistrationException; import javax.management.MBeanRegistrationException;
@ -87,7 +86,7 @@ public class JmxEndpointExporter implements InitializingBean, DisposableBean, Be
} }
private Collection<ObjectName> register() { private Collection<ObjectName> register() {
return this.endpoints.stream().map(this::register).collect(Collectors.toList()); return this.endpoints.stream().map(this::register).toList();
} }
private ObjectName register(ExposableJmxEndpoint endpoint) { private ObjectName register(ExposableJmxEndpoint endpoint) {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Date;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.springframework.boot.actuate.endpoint.EndpointId; import org.springframework.boot.actuate.endpoint.EndpointId;
@ -84,7 +83,9 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO
Method method = operationMethod.getMethod(); Method method = operationMethod.getMethod();
ManagedOperationParameter[] managed = jmxAttributeSource.getManagedOperationParameters(method); ManagedOperationParameter[] managed = jmxAttributeSource.getManagedOperationParameters(method);
if (managed.length == 0) { if (managed.length == 0) {
return asList(operationMethod.getParameters().stream().map(DiscoveredJmxOperationParameter::new)); Stream<JmxOperationParameter> parameters = operationMethod.getParameters().stream()
.map(DiscoveredJmxOperationParameter::new);
return parameters.toList();
} }
return mergeParameters(operationMethod.getParameters(), managed); return mergeParameters(operationMethod.getParameters(), managed);
} }
@ -98,10 +99,6 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO
return Collections.unmodifiableList(merged); return Collections.unmodifiableList(merged);
} }
private <T> List<T> asList(Stream<T> stream) {
return stream.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
}
@Override @Override
public String getName() { public String getName() {
return this.name; return this.name;

View File

@ -20,9 +20,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.springframework.boot.actuate.endpoint.EndpointId; import org.springframework.boot.actuate.endpoint.EndpointId;
@ -107,7 +105,7 @@ public class PathMappedEndpoints implements Iterable<PathMappedEndpoint> {
* @return all root paths * @return all root paths
*/ */
public Collection<String> getAllRootPaths() { public Collection<String> getAllRootPaths() {
return asList(stream().map(PathMappedEndpoint::getRootPath)); return stream().map(PathMappedEndpoint::getRootPath).toList();
} }
/** /**
@ -115,7 +113,7 @@ public class PathMappedEndpoints implements Iterable<PathMappedEndpoint> {
* @return all root paths * @return all root paths
*/ */
public Collection<String> getAllPaths() { public Collection<String> getAllPaths() {
return asList(stream().map(this::getPath)); return stream().map(this::getPath).toList();
} }
/** /**
@ -145,8 +143,4 @@ public class PathMappedEndpoints implements Iterable<PathMappedEndpoint> {
return (endpoint != null) ? this.basePath + "/" + endpoint.getRootPath() : null; return (endpoint != null) ? this.basePath + "/" + endpoint.getRootPath() : null;
} }
private <T> List<T> asList(Stream<T> stream) {
return stream.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
}
} }

View File

@ -21,7 +21,6 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.flywaydb.core.Flyway; import org.flywaydb.core.Flyway;
@ -117,7 +116,7 @@ public class FlywayEndpoint {
private final List<FlywayMigration> migrations; private final List<FlywayMigration> migrations;
private FlywayDescriptor(MigrationInfo[] 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<FlywayMigration> migrations) { public FlywayDescriptor(List<FlywayMigration> migrations) {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Comparator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -81,7 +80,7 @@ public class SimpleStatusAggregator implements StatusAggregator {
} }
private static List<String> getUniformCodes(Stream<String> codes) { private static List<String> getUniformCodes(Stream<String> codes) {
return codes.map(SimpleStatusAggregator::getUniformCode).collect(Collectors.toList()); return codes.map(SimpleStatusAggregator::getUniformCode).toList();
} }
private static String getUniformCode(String code) { private static String getUniformCode(String code) {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -87,8 +86,7 @@ public class LiquibaseEndpoint {
database.setDatabaseChangeLogLockTableName(liquibase.getDatabaseChangeLogLockTable()); database.setDatabaseChangeLogLockTableName(liquibase.getDatabaseChangeLogLockTable());
StandardChangeLogHistoryService service = new StandardChangeLogHistoryService(); StandardChangeLogHistoryService service = new StandardChangeLogHistoryService();
service.setDatabase(database); service.setDatabase(database);
return new LiquibaseBean( return new LiquibaseBean(service.getRanChangeSets().stream().map(ChangeSet::new).toList());
service.getRanChangeSets().stream().map(ChangeSet::new).collect(Collectors.toList()));
} }
finally { finally {
if (database != null) { if (database != null) {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
@ -73,8 +72,7 @@ class PlainTextThreadDumpFormatter {
} }
private List<MonitorInfo> lockedMonitorsForDepth(MonitorInfo[] lockedMonitors, int depth) { private List<MonitorInfo> lockedMonitorsForDepth(MonitorInfo[] lockedMonitors, int depth) {
return Stream.of(lockedMonitors).filter((lockedMonitor) -> lockedMonitor.getLockedStackDepth() == depth) return Stream.of(lockedMonitors).filter((candidate) -> candidate.getLockedStackDepth() == depth).toList();
.collect(Collectors.toList());
} }
private void writeStackTraceElement(PrintWriter writer, StackTraceElement element, ThreadInfo info, private void writeStackTraceElement(PrintWriter writer, StackTraceElement element, ThreadInfo info,

View File

@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.stream.Collectors;
import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
@ -92,10 +91,7 @@ public class MetricsEndpoint {
} }
private List<Tag> parseTags(List<String> tags) { private List<Tag> parseTags(List<String> tags) {
if (tags == null) { return (tags != null) ? tags.stream().map(this::parseTag).toList() : Collections.emptyList();
return Collections.emptyList();
}
return tags.stream().map(this::parseTag).collect(Collectors.toList());
} }
private Tag parseTag(String tag) { private Tag parseTag(String tag) {
@ -157,8 +153,7 @@ public class MetricsEndpoint {
} }
private <K, V, T> List<T> asList(Map<K, V> map, BiFunction<K, V, T> mapper) { private <K, V, T> List<T> asList(Map<K, V> map, BiFunction<K, V, T> mapper) {
return map.entrySet().stream().map((entry) -> mapper.apply(entry.getKey(), entry.getValue())) return map.entrySet().stream().map((entry) -> mapper.apply(entry.getKey(), entry.getValue())).toList();
.collect(Collectors.toList());
} }
/** /**

View File

@ -29,7 +29,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import org.quartz.CalendarIntervalTrigger; import org.quartz.CalendarIntervalTrigger;
import org.quartz.CronTrigger; import org.quartz.CronTrigger;
@ -99,7 +98,7 @@ public class QuartzEndpoint {
Map<String, Object> result = new LinkedHashMap<>(); Map<String, Object> result = new LinkedHashMap<>();
for (String groupName : this.scheduler.getJobGroupNames()) { for (String groupName : this.scheduler.getJobGroupNames()) {
List<String> jobs = this.scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName)).stream() List<String> 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)); result.put(groupName, Collections.singletonMap("jobs", jobs));
} }
return new QuartzGroups(result); return new QuartzGroups(result);
@ -117,7 +116,7 @@ public class QuartzEndpoint {
Map<String, Object> groupDetails = new LinkedHashMap<>(); Map<String, Object> groupDetails = new LinkedHashMap<>();
groupDetails.put("paused", pausedTriggerGroups.contains(groupName)); groupDetails.put("paused", pausedTriggerGroups.contains(groupName));
groupDetails.put("triggers", this.scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(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); result.put(groupName, groupDetails);
} }
return new QuartzGroups(result); return new QuartzGroups(result);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation; import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
@ -77,7 +76,7 @@ public class SessionsEndpoint {
private final List<SessionDescriptor> sessions; private final List<SessionDescriptor> sessions;
public SessionsReport(Map<String, ? extends Session> sessions) { public SessionsReport(Map<String, ? extends Session> sessions) {
this.sessions = sessions.values().stream().map(SessionDescriptor::new).collect(Collectors.toList()); this.sessions = sessions.values().stream().map(SessionDescriptor::new).toList();
} }
public List<SessionDescriptor> getSessions() { public List<SessionDescriptor> getSessions() {

View File

@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -79,7 +78,7 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc
} }
private List<DispatcherHandlerMappingDescription> describeMappings(DispatcherHandler dispatcherHandler) { private List<DispatcherHandlerMappingDescription> describeMappings(DispatcherHandler dispatcherHandler) {
return dispatcherHandler.getHandlerMappings().stream().flatMap(this::describe).collect(Collectors.toList()); return dispatcherHandler.getHandlerMappings().stream().flatMap(this::describe).toList();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -111,7 +110,7 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc
@Override @Override
public List<DispatcherHandlerMappingDescription> describe(RequestMappingInfoHandlerMapping handlerMapping) { public List<DispatcherHandlerMappingDescription> describe(RequestMappingInfoHandlerMapping handlerMapping) {
Map<RequestMappingInfo, HandlerMethod> handlerMethods = handlerMapping.getHandlerMethods(); Map<RequestMappingInfo, HandlerMethod> 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<RequestMappingInfo, HandlerMethod> mapping) { private DispatcherHandlerMappingDescription describe(Entry<RequestMappingInfo, HandlerMethod> mapping) {
@ -134,7 +133,7 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc
@Override @Override
public List<DispatcherHandlerMappingDescription> describe(AbstractUrlHandlerMapping handlerMapping) { public List<DispatcherHandlerMappingDescription> 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<PathPattern, Object> mapping) { private DispatcherHandlerMappingDescription describe(Entry<PathPattern, Object> mapping) {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; package org.springframework.boot.actuate.web.mappings.reactive;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -48,16 +49,16 @@ public class RequestMappingConditionsDescription {
RequestMappingConditionsDescription(RequestMappingInfo requestMapping) { RequestMappingConditionsDescription(RequestMappingInfo requestMapping) {
this.consumes = requestMapping.getConsumesCondition().getExpressions().stream() this.consumes = requestMapping.getConsumesCondition().getExpressions().stream()
.map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); .map(MediaTypeExpressionDescription::new).toList();
this.headers = requestMapping.getHeadersCondition().getExpressions().stream() this.headers = requestMapping.getHeadersCondition().getExpressions().stream()
.map(NameValueExpressionDescription::new).collect(Collectors.toList()); .map(NameValueExpressionDescription::new).toList();
this.methods = requestMapping.getMethodsCondition().getMethods(); this.methods = requestMapping.getMethodsCondition().getMethods();
this.params = requestMapping.getParamsCondition().getExpressions().stream() 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) 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() this.produces = requestMapping.getProducesCondition().getExpressions().stream()
.map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); .map(MediaTypeExpressionDescription::new).toList();
} }
public List<MediaTypeExpressionDescription> getConsumes() { public List<MediaTypeExpressionDescription> getConsumes() {

View File

@ -23,7 +23,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import jakarta.servlet.Servlet; import jakarta.servlet.Servlet;
@ -104,7 +103,7 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc
} }
private List<DispatcherServletMappingDescription> describeMappings(DispatcherServletHandlerMappings mappings) { private List<DispatcherServletMappingDescription> describeMappings(DispatcherServletHandlerMappings mappings) {
return mappings.getHandlerMappings().stream().flatMap(this::describe).collect(Collectors.toList()); return mappings.getHandlerMappings().stream().flatMap(this::describe).toList();
} }
private <T> Stream<DispatcherServletMappingDescription> describe(T handlerMapping) { private <T> Stream<DispatcherServletMappingDescription> describe(T handlerMapping) {
@ -141,7 +140,7 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc
@Override @Override
public List<DispatcherServletMappingDescription> describe(RequestMappingInfoHandlerMapping handlerMapping) { public List<DispatcherServletMappingDescription> describe(RequestMappingInfoHandlerMapping handlerMapping) {
Map<RequestMappingInfo, HandlerMethod> handlerMethods = handlerMapping.getHandlerMethods(); Map<RequestMappingInfo, HandlerMethod> 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<RequestMappingInfo, HandlerMethod> mapping) { private DispatcherServletMappingDescription describe(Entry<RequestMappingInfo, HandlerMethod> mapping) {
@ -164,7 +163,7 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc
@Override @Override
public List<DispatcherServletMappingDescription> describe(AbstractUrlHandlerMapping handlerMapping) { public List<DispatcherServletMappingDescription> 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<String, Object> mapping) { private DispatcherServletMappingDescription describe(Entry<String, Object> mapping) {

View File

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.web.mappings.servlet;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import jakarta.servlet.Filter; import jakarta.servlet.Filter;
import jakarta.servlet.ServletContext; import jakarta.servlet.ServletContext;
@ -46,7 +45,7 @@ public class FiltersMappingDescriptionProvider implements MappingDescriptionProv
public List<FilterRegistrationMappingDescription> describeMappings(ApplicationContext context) { public List<FilterRegistrationMappingDescription> describeMappings(ApplicationContext context) {
if (context instanceof WebApplicationContext webApplicationContext) { if (context instanceof WebApplicationContext webApplicationContext) {
return webApplicationContext.getServletContext().getFilterRegistrations().values().stream() return webApplicationContext.getServletContext().getFilterRegistrations().values().stream()
.map(FilterRegistrationMappingDescription::new).collect(Collectors.toList()); .map(FilterRegistrationMappingDescription::new).toList();
} }
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.condition.MediaTypeExpression; import org.springframework.web.servlet.mvc.condition.MediaTypeExpression;
@ -48,15 +47,15 @@ public class RequestMappingConditionsDescription {
RequestMappingConditionsDescription(RequestMappingInfo requestMapping) { RequestMappingConditionsDescription(RequestMappingInfo requestMapping) {
this.consumes = requestMapping.getConsumesCondition().getExpressions().stream() this.consumes = requestMapping.getConsumesCondition().getExpressions().stream()
.map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); .map(MediaTypeExpressionDescription::new).toList();
this.headers = requestMapping.getHeadersCondition().getExpressions().stream() this.headers = requestMapping.getHeadersCondition().getExpressions().stream()
.map(NameValueExpressionDescription::new).collect(Collectors.toList()); .map(NameValueExpressionDescription::new).toList();
this.methods = requestMapping.getMethodsCondition().getMethods(); this.methods = requestMapping.getMethodsCondition().getMethods();
this.params = requestMapping.getParamsCondition().getExpressions().stream() this.params = requestMapping.getParamsCondition().getExpressions().stream()
.map(NameValueExpressionDescription::new).collect(Collectors.toList()); .map(NameValueExpressionDescription::new).toList();
this.patterns = extractPathPatterns(requestMapping); this.patterns = extractPathPatterns(requestMapping);
this.produces = requestMapping.getProducesCondition().getExpressions().stream() this.produces = requestMapping.getProducesCondition().getExpressions().stream()
.map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); .map(MediaTypeExpressionDescription::new).toList();
} }
private Set<String> extractPathPatterns(RequestMappingInfo requestMapping) { private Set<String> extractPathPatterns(RequestMappingInfo requestMapping) {

View File

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.web.mappings.servlet;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import jakarta.servlet.Servlet; import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContext; import jakarta.servlet.ServletContext;
@ -46,7 +45,7 @@ public class ServletsMappingDescriptionProvider implements MappingDescriptionPro
public List<ServletRegistrationMappingDescription> describeMappings(ApplicationContext context) { public List<ServletRegistrationMappingDescription> describeMappings(ApplicationContext context) {
if (context instanceof WebApplicationContext webApplicationContext) { if (context instanceof WebApplicationContext webApplicationContext) {
return webApplicationContext.getServletContext().getServletRegistrations().values().stream() return webApplicationContext.getServletContext().getServletRegistrations().values().stream()
.map(ServletRegistrationMappingDescription::new).collect(Collectors.toList()); .map(ServletRegistrationMappingDescription::new).toList();
} }
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -67,7 +66,7 @@ class BeansEndpointTests {
.getAutowireCapableBeanFactory(); .getAutowireCapableBeanFactory();
List<String> infrastructureBeans = Stream.of(context.getBeanDefinitionNames()) List<String> infrastructureBeans = Stream.of(context.getBeanDefinitionNames())
.filter((name) -> BeanDefinition.ROLE_INFRASTRUCTURE == factory.getBeanDefinition(name).getRole()) .filter((name) -> BeanDefinition.ROLE_INFRASTRUCTURE == factory.getBeanDefinition(name).getRole())
.collect(Collectors.toList()); .toList();
ApplicationBeans result = context.getBean(BeansEndpoint.class).beans(); ApplicationBeans result = context.getBean(BeansEndpoint.class).beans();
ContextBeans contextDescriptor = result.getContexts().get(context.getId()); ContextBeans contextDescriptor = result.getContexts().get(context.getId());
Map<String, BeanDescriptor> beans = contextDescriptor.getBeans(); Map<String, BeanDescriptor> beans = contextDescriptor.getBeans();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.List;
import java.util.Spliterator; import java.util.Spliterator;
import java.util.Spliterators; import java.util.Spliterators;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
@ -107,7 +106,7 @@ class OperationMethodParametersTests {
} }
private void assertParameters(Stream<OperationParameter> stream) { private void assertParameters(Stream<OperationParameter> stream) {
List<OperationParameter> parameters = stream.collect(Collectors.toList()); List<OperationParameter> parameters = stream.toList();
assertThat(parameters).hasSize(1); assertThat(parameters).hasSize(1);
OperationParameter parameter = parameters.get(0); OperationParameter parameter = parameters.get(0);
assertThat(parameter.getName()).isEqualTo("name"); assertThat(parameter.getName()).isEqualTo("name");

View File

@ -20,7 +20,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -118,8 +117,7 @@ class ControllerEndpointDiscovererTests {
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class) this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
.run(assertDiscoverer((discoverer) -> { .run(assertDiscoverer((discoverer) -> {
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints(); Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
List<EndpointId> ids = endpoints.stream().map(ExposableControllerEndpoint::getEndpointId) List<EndpointId> ids = endpoints.stream().map(ExposableControllerEndpoint::getEndpointId).toList();
.collect(Collectors.toList());
assertThat(ids).containsOnly(EndpointId.of("testcontroller"), EndpointId.of("testrestcontroller")); assertThat(ids).containsOnly(EndpointId.of("testcontroller"), EndpointId.of("testrestcontroller"));
})); }));
} }

View File

@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors;
import jakarta.servlet.GenericServlet; import jakarta.servlet.GenericServlet;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
@ -100,8 +99,7 @@ class ServletEndpointDiscovererTests {
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class) this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
.run(assertDiscoverer((discoverer) -> { .run(assertDiscoverer((discoverer) -> {
Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints(); Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints();
List<EndpointId> ids = endpoints.stream().map(ExposableServletEndpoint::getEndpointId) List<EndpointId> ids = endpoints.stream().map(ExposableServletEndpoint::getEndpointId).toList();
.collect(Collectors.toList());
assertThat(ids).containsOnly(EndpointId.of("testservlet")); assertThat(ids).containsOnly(EndpointId.of("testservlet"));
})); }));
} }

View File

@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.assertj.core.api.Condition; import org.assertj.core.api.Condition;
@ -255,7 +254,7 @@ class WebEndpointDiscovererTests {
} }
private List<WebOperationRequestPredicate> requestPredicates(ExposableWebEndpoint endpoint) { private List<WebOperationRequestPredicate> requestPredicates(ExposableWebEndpoint endpoint) {
return endpoint.getOperations().stream().map(WebOperation::getRequestPredicate).collect(Collectors.toList()); return endpoint.getOperations().stream().map(WebOperation::getRequestPredicate).toList();
} }
private Condition<List<? extends WebOperationRequestPredicate>> requestPredicates( private Condition<List<? extends WebOperationRequestPredicate>> requestPredicates(

View File

@ -103,12 +103,12 @@ class DefaultWebMvcTagsProviderTests {
@Override @Override
public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response, Object handler, public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response, Object handler,
Throwable exception) { 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 @Override
public Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object handler) { public Iterable<Tag> 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();
} }
} }

View File

@ -17,6 +17,7 @@
package org.springframework.boot.actuate.endpoint.web.test; package org.springframework.boot.actuate.endpoint.web.test;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -144,7 +145,7 @@ class WebEndpointTestInvocationContextProvider implements TestTemplateInvocation
public void beforeEach(ExtensionContext extensionContext) throws Exception { public void beforeEach(ExtensionContext extensionContext) throws Exception {
List<Class<?>> configurationClasses = Stream List<Class<?>> configurationClasses = Stream
.of(extensionContext.getRequiredTestClass().getDeclaredClasses()).filter(this::isConfiguration) .of(extensionContext.getRequiredTestClass().getDeclaredClasses()).filter(this::isConfiguration)
.collect(Collectors.toList()); .collect(Collectors.toCollection(ArrayList::new));
this.context = this.contextFactory.apply(configurationClasses); this.context = this.contextFactory.apply(configurationClasses);
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest; import org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest;
@ -51,7 +50,7 @@ class InfoEndpointWebIntegrationTests {
@Bean @Bean
InfoEndpoint endpoint(ObjectProvider<InfoContributor> infoContributors) { InfoEndpoint endpoint(ObjectProvider<InfoContributor> infoContributors) {
return new InfoEndpoint(infoContributors.orderedStream().collect(Collectors.toList())); return new InfoEndpoint(infoContributors.orderedStream().toList());
} }
@Bean @Bean

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -71,7 +71,7 @@ class DefaultWebFluxTagsProviderTests {
@Override @Override
public Iterable<Tag> httpRequestTags(ServerWebExchange exchange, Throwable ex) { public Iterable<Tag> 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();
} }
} }

View File

@ -446,8 +446,7 @@ public class AutoConfigurationImportSelector implements DeferredImportSelector,
processedConfigurations.removeAll(allExclusions); processedConfigurations.removeAll(allExclusions);
return sortAutoConfigurations(processedConfigurations, getAutoConfigurationMetadata()).stream() return sortAutoConfigurations(processedConfigurations, getAutoConfigurationMetadata()).stream()
.map((importClassName) -> new Entry(this.entries.get(importClassName), importClassName)) .map((importClassName) -> new Entry(this.entries.get(importClassName), importClassName)).toList();
.collect(Collectors.toList());
} }
private AutoConfigurationMetadata getAutoConfigurationMetadata() { private AutoConfigurationMetadata getAutoConfigurationMetadata() {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 @Override
protected Collection<Class<?>> sort(Collection<Class<?>> classes) { protected Collection<Class<?>> sort(Collection<Class<?>> classes) {
List<String> names = classes.stream().map(Class::getName).collect(Collectors.toList()); List<String> names = classes.stream().map(Class::getName).toList();
List<String> sorted = SORTER.getInPriorityOrder(names); List<String> sorted = SORTER.getInPriorityOrder(names);
return sorted.stream().map((className) -> ClassUtils.resolveClassName(className, null)) return sorted.stream().map((className) -> ClassUtils.resolveClassName(className, null))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.amqp; package org.springframework.boot.autoconfigure.amqp;
import java.util.stream.Collectors;
import org.springframework.amqp.rabbit.annotation.EnableRabbit; import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.config.ContainerCustomizer; import org.springframework.amqp.rabbit.config.ContainerCustomizer;
import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory;
@ -69,8 +67,7 @@ class RabbitAnnotationDrivenConfiguration {
this.properties); this.properties);
configurer.setMessageConverter(this.messageConverter.getIfUnique()); configurer.setMessageConverter(this.messageConverter.getIfUnique());
configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique()); configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique());
configurer.setRetryTemplateCustomizers( configurer.setRetryTemplateCustomizers(this.retryTemplateCustomizers.orderedStream().toList());
this.retryTemplateCustomizers.orderedStream().collect(Collectors.toList()));
return configurer; return configurer;
} }
@ -94,8 +91,7 @@ class RabbitAnnotationDrivenConfiguration {
this.properties); this.properties);
configurer.setMessageConverter(this.messageConverter.getIfUnique()); configurer.setMessageConverter(this.messageConverter.getIfUnique());
configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique()); configurer.setMessageRecoverer(this.messageRecoverer.getIfUnique());
configurer.setRetryTemplateCustomizers( configurer.setRetryTemplateCustomizers(this.retryTemplateCustomizers.orderedStream().toList());
this.retryTemplateCustomizers.orderedStream().collect(Collectors.toList()));
return configurer; return configurer;
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.amqp; package org.springframework.boot.autoconfigure.amqp;
import java.util.stream.Collectors;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.rabbitmq.client.impl.CredentialsProvider; import com.rabbitmq.client.impl.CredentialsProvider;
import com.rabbitmq.client.impl.CredentialsRefreshService; import com.rabbitmq.client.impl.CredentialsRefreshService;
@ -149,8 +147,7 @@ public class RabbitAutoConfiguration {
ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) { ObjectProvider<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) {
RabbitTemplateConfigurer configurer = new RabbitTemplateConfigurer(properties); RabbitTemplateConfigurer configurer = new RabbitTemplateConfigurer(properties);
configurer.setMessageConverter(messageConverter.getIfUnique()); configurer.setMessageConverter(messageConverter.getIfUnique());
configurer configurer.setRetryTemplateCustomizers(retryTemplateCustomizers.orderedStream().toList());
.setRetryTemplateCustomizers(retryTemplateCustomizers.orderedStream().collect(Collectors.toList()));
return configurer; return configurer;
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.cache; package org.springframework.boot.autoconfigure.cache;
import java.util.stream.Collectors;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
@ -67,7 +65,7 @@ public class CacheAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public CacheManagerCustomizers cacheManagerCustomizers(ObjectProvider<CacheManagerCustomizer<?>> customizers) { public CacheManagerCustomizers cacheManagerCustomizers(ObjectProvider<CacheManagerCustomizer<?>> customizers) {
return new CacheManagerCustomizers(customizers.orderedStream().collect(Collectors.toList())); return new CacheManagerCustomizers(customizers.orderedStream().toList());
} }
@Bean @Bean

View File

@ -24,7 +24,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
@ -222,8 +221,7 @@ public class CassandraAutoConfiguration {
private List<String> mapContactPoints(CassandraProperties properties) { private List<String> mapContactPoints(CassandraProperties properties) {
if (properties.getContactPoints() != null) { if (properties.getContactPoints() != null) {
return properties.getContactPoints().stream() return properties.getContactPoints().stream()
.map((candidate) -> formatContactPoint(candidate, properties.getPort())) .map((candidate) -> formatContactPoint(candidate, properties.getPort())).toList();
.collect(Collectors.toList());
} }
return null; return null;
} }

View File

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.condition;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style; import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style;
import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.Condition;
@ -51,7 +50,7 @@ class OnPropertyCondition extends SpringBootCondition {
List<AnnotationAttributes> allAnnotationAttributes = metadata.getAnnotations() List<AnnotationAttributes> allAnnotationAttributes = metadata.getAnnotations()
.stream(ConditionalOnProperty.class.getName()) .stream(ConditionalOnProperty.class.getName())
.filter(MergedAnnotationPredicates.unique(MergedAnnotation::getMetaTypes)) .filter(MergedAnnotationPredicates.unique(MergedAnnotation::getMetaTypes))
.map(MergedAnnotation::asAnnotationAttributes).collect(Collectors.toList()); .map(MergedAnnotation::asAnnotationAttributes).toList();
List<ConditionMessage> noMatch = new ArrayList<>(); List<ConditionMessage> noMatch = new ArrayList<>();
List<ConditionMessage> match = new ArrayList<>(); List<ConditionMessage> match = new ArrayList<>();
for (AnnotationAttributes annotationAttributes : allAnnotationAttributes) { for (AnnotationAttributes annotationAttributes : allAnnotationAttributes) {

View File

@ -24,7 +24,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
@ -137,7 +136,7 @@ class NoSuchBeanDefinitionFailureAnalyzer extends AbstractInjectionFailureAnalyz
return Arrays.stream(beanNames) return Arrays.stream(beanNames)
.map((beanName) -> new UserConfigurationResult(getFactoryMethodMetadata(beanName), .map((beanName) -> new UserConfigurationResult(getFactoryMethodMetadata(beanName),
this.beanFactory.getBean(beanName).equals(null))) this.beanFactory.getBean(beanName).equals(null)))
.collect(Collectors.toList()); .toList();
} }
private MethodMetadata getFactoryMethodMetadata(String beanName) { private MethodMetadata getFactoryMethodMetadata(String beanName) {

View File

@ -24,7 +24,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -117,10 +116,8 @@ public class FlywayAutoConfiguration {
FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader()); FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader());
configureDataSource(configuration, properties, flywayDataSource.getIfAvailable(), dataSource.getIfUnique()); configureDataSource(configuration, properties, flywayDataSource.getIfAvailable(), dataSource.getIfUnique());
configureProperties(configuration, properties); configureProperties(configuration, properties);
List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList()); configureCallbacks(configuration, callbacks.orderedStream().toList());
configureCallbacks(configuration, orderedCallbacks); configureJavaMigrations(configuration, javaMigrations.orderedStream().toList());
List<JavaMigration> migrations = javaMigrations.stream().collect(Collectors.toList());
configureJavaMigrations(configuration, migrations);
fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration)); fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration));
return configuration.load(); return configuration.load();
} }
@ -282,8 +279,7 @@ public class FlywayAutoConfiguration {
return locations; return locations;
} }
String vendor = databaseDriver.getId(); String vendor = databaseDriver.getId();
return locations.stream().map((location) -> location.replace(VENDOR_PLACEHOLDER, vendor)) return locations.stream().map((location) -> location.replace(VENDOR_PLACEHOLDER, vendor)).toList();
.collect(Collectors.toList());
} }
private DatabaseDriver getDatabaseDriver() { private DatabaseDriver getDatabaseDriver() {

View File

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import graphql.GraphQL; import graphql.GraphQL;
import graphql.execution.instrumentation.Instrumentation; import graphql.execution.instrumentation.Instrumentation;
@ -84,9 +83,9 @@ public class GraphQlAutoConfiguration {
Resource[] schemaResources = resolveSchemaResources(resourcePatternResolver, schemaLocations, Resource[] schemaResources = resolveSchemaResources(resourcePatternResolver, schemaLocations,
properties.getSchema().getFileExtensions()); properties.getSchema().getFileExtensions());
GraphQlSource.SchemaResourceBuilder builder = GraphQlSource.schemaResourceBuilder() GraphQlSource.SchemaResourceBuilder builder = GraphQlSource.schemaResourceBuilder()
.schemaResources(schemaResources).exceptionResolvers(toList(exceptionResolvers)) .schemaResources(schemaResources).exceptionResolvers(exceptionResolvers.orderedStream().toList())
.subscriptionExceptionResolvers(toList(subscriptionExceptionResolvers)) .subscriptionExceptionResolvers(subscriptionExceptionResolvers.orderedStream().toList())
.instrumentation(toList(instrumentations)); .instrumentation(instrumentations.orderedStream().toList());
if (!properties.getSchema().getIntrospection().isEnabled()) { if (!properties.getSchema().getIntrospection().isEnabled()) {
builder.configureRuntimeWiring(this::enableIntrospection); builder.configureRuntimeWiring(this::enableIntrospection);
} }
@ -144,8 +143,4 @@ public class GraphQlAutoConfiguration {
return controllerConfigurer; return controllerConfigurer;
} }
private <T> List<T> toList(ObjectProvider<T> provider) {
return provider.orderedStream().collect(Collectors.toList());
}
} }

View File

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.graphql.data;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer; import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer;
@ -47,15 +46,13 @@ class GraphQlQuerydslSourceBuilderCustomizer<E, R> implements GraphQlSourceBuild
GraphQlQuerydslSourceBuilderCustomizer( GraphQlQuerydslSourceBuilderCustomizer(
BiFunction<List<E>, List<R>, RuntimeWiringConfigurer> wiringConfigurerFactory, ObjectProvider<E> executors, BiFunction<List<E>, List<R>, RuntimeWiringConfigurer> wiringConfigurerFactory, ObjectProvider<E> executors,
ObjectProvider<R> reactiveExecutors) { ObjectProvider<R> reactiveExecutors) {
this(wiringConfigurerFactory, toList(executors), toList(reactiveExecutors)); this.wiringConfigurerFactory = wiringConfigurerFactory;
this.executors = asList(executors);
this.reactiveExecutors = asList(reactiveExecutors);
} }
GraphQlQuerydslSourceBuilderCustomizer( private static <T> List<T> asList(ObjectProvider<T> provider) {
BiFunction<List<E>, List<R>, RuntimeWiringConfigurer> wiringConfigurerFactory, List<E> executors, return (provider != null) ? provider.orderedStream().toList() : Collections.emptyList();
List<R> reactiveExecutors) {
this.wiringConfigurerFactory = wiringConfigurerFactory;
this.executors = executors;
this.reactiveExecutors = reactiveExecutors;
} }
@Override @Override
@ -65,8 +62,4 @@ class GraphQlQuerydslSourceBuilderCustomizer<E, R> implements GraphQlSourceBuild
} }
} }
private static <T> List<T> toList(ObjectProvider<T> provider) {
return (provider != null) ? provider.orderedStream().collect(Collectors.toList()) : Collections.emptyList();
}
} }

View File

@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.graphql.reactive; package org.springframework.boot.autoconfigure.graphql.reactive;
import java.util.Collections; import java.util.Collections;
import java.util.stream.Collectors;
import graphql.GraphQL; import graphql.GraphQL;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -96,9 +95,8 @@ public class GraphQlWebFluxAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service,
ObjectProvider<WebGraphQlInterceptor> interceptorsProvider) { ObjectProvider<WebGraphQlInterceptor> interceptors) {
return WebGraphQlHandler.builder(service) return WebGraphQlHandler.builder(service).interceptors(interceptors.orderedStream().toList()).build();
.interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList())).build();
} }
@Bean @Bean

View File

@ -16,9 +16,6 @@
package org.springframework.boot.autoconfigure.graphql.rsocket; package org.springframework.boot.autoconfigure.graphql.rsocket;
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import graphql.GraphQL; import graphql.GraphQL;
import io.rsocket.core.RSocketServer; import io.rsocket.core.RSocketServer;
@ -58,10 +55,9 @@ public class GraphQlRSocketAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public GraphQlRSocketHandler graphQlRSocketHandler(ExecutionGraphQlService graphQlService, public GraphQlRSocketHandler graphQlRSocketHandler(ExecutionGraphQlService graphQlService,
ObjectProvider<RSocketGraphQlInterceptor> interceptorsProvider, ObjectMapper objectMapper) { ObjectProvider<RSocketGraphQlInterceptor> interceptors, ObjectMapper objectMapper) {
List<RSocketGraphQlInterceptor> interceptors = interceptorsProvider.orderedStream() return new GraphQlRSocketHandler(graphQlService, interceptors.orderedStream().toList(),
.collect(Collectors.toList()); new Jackson2JsonEncoder(objectMapper));
return new GraphQlRSocketHandler(graphQlService, interceptors, new Jackson2JsonEncoder(objectMapper));
} }
@Bean @Bean

View File

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.graphql.servlet;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import graphql.GraphQL; import graphql.GraphQL;
import jakarta.websocket.server.ServerContainer; import jakarta.websocket.server.ServerContainer;
@ -97,9 +96,8 @@ public class GraphQlWebMvcAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service, public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service,
ObjectProvider<WebGraphQlInterceptor> interceptorsProvider) { ObjectProvider<WebGraphQlInterceptor> interceptors) {
return WebGraphQlHandler.builder(service) return WebGraphQlHandler.builder(service).interceptors(interceptors.orderedStream().toList()).build();
.interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList())).build();
} }
@Bean @Bean

View File

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.h2;
import java.sql.Connection; import java.sql.Connection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import javax.sql.DataSource; 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.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.core.log.LogMessage;
/** /**
* {@link EnableAutoConfiguration Auto-configuration} for H2's web console. * {@link EnableAutoConfiguration Auto-configuration} for H2's web console.
@ -83,20 +83,19 @@ public class H2ConsoleAutoConfiguration {
} }
private void logDataSources(ObjectProvider<DataSource> dataSource, String path) { private void logDataSources(ObjectProvider<DataSource> dataSource, String path) {
List<String> urls = dataSource.orderedStream().map((available) -> { List<String> urls = dataSource.orderedStream().map(this::getConnectionUrl).filter(Objects::nonNull).toList();
try (Connection connection = available.getConnection()) {
return "'" + connection.getMetaData().getURL() + "'";
}
catch (Exception ex) {
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
if (!urls.isEmpty()) { if (!urls.isEmpty()) {
StringBuilder sb = new StringBuilder("H2 console available at '").append(path).append("'. "); logger.info(LogMessage.format("H2 console available at '%s'. %s available at %s", path,
String tmp = (urls.size() > 1) ? "Databases" : "Database"; (urls.size() > 1) ? "Databases" : "Database", String.join(", ", urls)));
sb.append(tmp).append(" available at "); }
sb.append(String.join(", ", urls)); }
logger.info(sb.toString());
private String getConnectionUrl(DataSource dataSource) {
try (Connection connection = dataSource.getConnection()) {
return "'" + connection.getMetaData().getURL() + "'";
}
catch (Exception ex) {
return null;
} }
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.http; package org.springframework.boot.autoconfigure.http;
import java.util.stream.Collectors;
import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
@ -73,7 +71,7 @@ public class HttpMessageConvertersAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) { public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) {
return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList())); return new HttpMessageConverters(converters.orderedStream().toList());
} }
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)

View File

@ -16,9 +16,6 @@
package org.springframework.boot.autoconfigure.jms.artemis; 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.QueueConfiguration;
import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration; import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
@ -90,19 +87,13 @@ class ArtemisEmbeddedServerConfiguration {
JMSConfiguration artemisJmsConfiguration(ObjectProvider<JMSQueueConfiguration> queuesConfiguration, JMSConfiguration artemisJmsConfiguration(ObjectProvider<JMSQueueConfiguration> queuesConfiguration,
ObjectProvider<TopicConfiguration> topicsConfiguration) { ObjectProvider<TopicConfiguration> topicsConfiguration) {
JMSConfiguration configuration = new JMSConfigurationImpl(); JMSConfiguration configuration = new JMSConfigurationImpl();
addAll(configuration.getQueueConfigurations(), queuesConfiguration); configuration.getQueueConfigurations().addAll(queuesConfiguration.orderedStream().toList());
addAll(configuration.getTopicConfigurations(), topicsConfiguration); configuration.getTopicConfigurations().addAll(topicsConfiguration.orderedStream().toList());
addQueues(configuration, this.properties.getEmbedded().getQueues()); addQueues(configuration, this.properties.getEmbedded().getQueues());
addTopics(configuration, this.properties.getEmbedded().getTopics()); addTopics(configuration, this.properties.getEmbedded().getTopics());
return configuration; return configuration;
} }
private <T> void addAll(List<T> list, ObjectProvider<T> items) {
if (items != null) {
list.addAll(items.orderedStream().collect(Collectors.toList()));
}
}
private void addQueues(JMSConfiguration configuration, String[] queues) { private void addQueues(JMSConfiguration configuration, String[] queues) {
boolean persistent = this.properties.getEmbedded().isPersistent(); boolean persistent = this.properties.getEmbedded().isPersistent();
for (String queue : queues) { for (String queue : queues) {

View File

@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcome; 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("Positive matches:%n"));
message.append(String.format("-----------------%n")); message.append(String.format("-----------------%n"));
List<Entry<String, ConditionAndOutcomes>> matched = shortOutcomes.entrySet().stream() List<Entry<String, ConditionAndOutcomes>> matched = shortOutcomes.entrySet().stream()
.filter((entry) -> entry.getValue().isFullMatch()).collect(Collectors.toList()); .filter((entry) -> entry.getValue().isFullMatch()).toList();
if (matched.isEmpty()) { if (matched.isEmpty()) {
message.append(String.format("%n None%n")); 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("Negative matches:%n"));
message.append(String.format("-----------------%n")); message.append(String.format("-----------------%n"));
List<Entry<String, ConditionAndOutcomes>> nonMatched = shortOutcomes.entrySet().stream() List<Entry<String, ConditionAndOutcomes>> nonMatched = shortOutcomes.entrySet().stream()
.filter((entry) -> !entry.getValue().isFullMatch()).collect(Collectors.toList()); .filter((entry) -> !entry.getValue().isFullMatch()).toList();
if (nonMatched.isEmpty()) { if (nonMatched.isEmpty()) {
message.append(String.format("%n None%n")); message.append(String.format("%n None%n"));
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.mongo; package org.springframework.boot.autoconfigure.mongo;
import java.util.stream.Collectors;
import com.mongodb.MongoClientSettings; import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClient;
@ -51,8 +49,7 @@ public class MongoAutoConfiguration {
@ConditionalOnMissingBean(MongoClient.class) @ConditionalOnMissingBean(MongoClient.class)
public MongoClient mongo(ObjectProvider<MongoClientSettingsBuilderCustomizer> builderCustomizers, public MongoClient mongo(ObjectProvider<MongoClientSettingsBuilderCustomizer> builderCustomizers,
MongoClientSettings settings) { MongoClientSettings settings) {
return new MongoClientFactory(builderCustomizers.orderedStream().collect(Collectors.toList())) return new MongoClientFactory(builderCustomizers.orderedStream().toList()).createMongoClient(settings);
.createMongoClient(settings);
} }
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.mongo; package org.springframework.boot.autoconfigure.mongo;
import java.util.stream.Collectors;
import com.mongodb.MongoClientSettings; import com.mongodb.MongoClientSettings;
import com.mongodb.MongoClientSettings.Builder; import com.mongodb.MongoClientSettings.Builder;
import com.mongodb.connection.netty.NettyStreamFactoryFactory; import com.mongodb.connection.netty.NettyStreamFactoryFactory;
@ -57,7 +55,7 @@ public class MongoReactiveAutoConfiguration {
public MongoClient reactiveStreamsMongoClient( public MongoClient reactiveStreamsMongoClient(
ObjectProvider<MongoClientSettingsBuilderCustomizer> builderCustomizers, MongoClientSettings settings) { ObjectProvider<MongoClientSettingsBuilderCustomizer> builderCustomizers, MongoClientSettings settings) {
ReactiveMongoClientFactory factory = new ReactiveMongoClientFactory( ReactiveMongoClientFactory factory = new ReactiveMongoClientFactory(
builderCustomizers.orderedStream().collect(Collectors.toList())); builderCustomizers.orderedStream().toList());
return factory.createMongoClient(settings); return factory.createMongoClient(settings);
} }

View File

@ -22,7 +22,6 @@ import java.time.Duration;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.neo4j.driver.AuthToken; import org.neo4j.driver.AuthToken;
import org.neo4j.driver.AuthTokens; import org.neo4j.driver.AuthTokens;
@ -64,8 +63,7 @@ public class Neo4jAutoConfiguration {
public Driver neo4jDriver(Neo4jProperties properties, Environment environment, public Driver neo4jDriver(Neo4jProperties properties, Environment environment,
ObjectProvider<ConfigBuilderCustomizer> configBuilderCustomizers) { ObjectProvider<ConfigBuilderCustomizer> configBuilderCustomizers) {
AuthToken authToken = mapAuthToken(properties.getAuthentication(), environment); AuthToken authToken = mapAuthToken(properties.getAuthentication(), environment);
Config config = mapDriverConfig(properties, Config config = mapDriverConfig(properties, configBuilderCustomizers.orderedStream().toList());
configBuilderCustomizers.orderedStream().collect(Collectors.toList()));
URI serverUri = determineServerUri(properties, environment); URI serverUri = determineServerUri(properties, environment);
return GraphDatabase.driver(serverUri, authToken, config); return GraphDatabase.driver(serverUri, authToken, config);
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.List;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -99,7 +98,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
this.poolMetadataProvider = new CompositeDataSourcePoolMetadataProvider(metadataProviders.getIfAvailable()); this.poolMetadataProvider = new CompositeDataSourcePoolMetadataProvider(metadataProviders.getIfAvailable());
this.hibernatePropertiesCustomizers = determineHibernatePropertiesCustomizers( this.hibernatePropertiesCustomizers = determineHibernatePropertiesCustomizers(
physicalNamingStrategy.getIfAvailable(), implicitNamingStrategy.getIfAvailable(), beanFactory, physicalNamingStrategy.getIfAvailable(), implicitNamingStrategy.getIfAvailable(), beanFactory,
hibernatePropertiesCustomizers.orderedStream().collect(Collectors.toList())); hibernatePropertiesCustomizers.orderedStream().toList());
} }
private List<HibernatePropertiesCustomizer> determineHibernatePropertiesCustomizers( private List<HibernatePropertiesCustomizer> determineHibernatePropertiesCustomizers(

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.r2dbc; package org.springframework.boot.autoconfigure.r2dbc;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import io.r2dbc.pool.ConnectionPool; import io.r2dbc.pool.ConnectionPool;
import io.r2dbc.pool.ConnectionPoolConfiguration; import io.r2dbc.pool.ConnectionPoolConfiguration;
@ -90,7 +89,7 @@ abstract class ConnectionFactoryConfigurations {
ConnectionPool connectionFactory(R2dbcProperties properties, ResourceLoader resourceLoader, ConnectionPool connectionFactory(R2dbcProperties properties, ResourceLoader resourceLoader,
ObjectProvider<ConnectionFactoryOptionsBuilderCustomizer> customizers) { ObjectProvider<ConnectionFactoryOptionsBuilderCustomizer> customizers) {
ConnectionFactory connectionFactory = createConnectionFactory(properties, ConnectionFactory connectionFactory = createConnectionFactory(properties,
resourceLoader.getClassLoader(), customizers.orderedStream().collect(Collectors.toList())); resourceLoader.getClassLoader(), customizers.orderedStream().toList());
R2dbcProperties.Pool pool = properties.getPool(); R2dbcProperties.Pool pool = properties.getPool();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
ConnectionPoolConfiguration.Builder builder = ConnectionPoolConfiguration.builder(connectionFactory); ConnectionPoolConfiguration.Builder builder = ConnectionPoolConfiguration.builder(connectionFactory);
@ -119,7 +118,7 @@ abstract class ConnectionFactoryConfigurations {
ConnectionFactory connectionFactory(R2dbcProperties properties, ResourceLoader resourceLoader, ConnectionFactory connectionFactory(R2dbcProperties properties, ResourceLoader resourceLoader,
ObjectProvider<ConnectionFactoryOptionsBuilderCustomizer> customizers) { ObjectProvider<ConnectionFactoryOptionsBuilderCustomizer> customizers) {
return createConnectionFactory(properties, resourceLoader.getClassLoader(), return createConnectionFactory(properties, resourceLoader.getClassLoader(),
customizers.orderedStream().collect(Collectors.toList())); customizers.orderedStream().toList());
} }
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.rsocket; package org.springframework.boot.autoconfigure.rsocket;
import java.util.stream.Collectors;
import io.rsocket.core.RSocketServer; import io.rsocket.core.RSocketServer;
import io.rsocket.frame.decoder.PayloadDecoder; import io.rsocket.frame.decoder.PayloadDecoder;
import io.rsocket.transport.netty.server.TcpServerTransport; 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().getPort()).to(factory::setPort);
map.from(properties.getServer().getFragmentSize()).to(factory::setFragmentSize); map.from(properties.getServer().getFragmentSize()).to(factory::setFragmentSize);
map.from(properties.getServer().getSsl()).to(factory::setSsl); map.from(properties.getServer().getSsl()).to(factory::setSsl);
factory.setRSocketServerCustomizers(customizers.orderedStream().collect(Collectors.toList())); factory.setRSocketServerCustomizers(customizers.orderedStream().toList());
return factory; return factory;
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.rsocket; package org.springframework.boot.autoconfigure.rsocket;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import io.rsocket.SocketAcceptor; import io.rsocket.SocketAcceptor;
@ -46,7 +45,7 @@ class RSocketWebSocketNettyRouteProvider implements NettyRouteProvider {
Stream<RSocketServerCustomizer> customizers) { Stream<RSocketServerCustomizer> customizers) {
this.mappingPath = mappingPath; this.mappingPath = mappingPath;
this.socketAcceptor = socketAcceptor; this.socketAcceptor = socketAcceptor;
this.customizers = customizers.collect(Collectors.toList()); this.customizers = customizers.toList();
} }
@Override @Override

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.EnumSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -123,18 +121,17 @@ public final class StaticResourceRequest {
return new StaticResourceServerWebExchange(subset); return new StaticResourceServerWebExchange(subset);
} }
private List<ServerWebExchangeMatcher> getDelegateMatchers() {
return getPatterns().map(PathPatternParserServerWebExchangeMatcher::new).collect(Collectors.toList());
}
private Stream<String> getPatterns() { private Stream<String> getPatterns() {
return this.locations.stream().flatMap(StaticResourceLocation::getPatterns); return this.locations.stream().flatMap(StaticResourceLocation::getPatterns);
} }
@Override @Override
public Mono<MatchResult> matches(ServerWebExchange exchange) { public Mono<MatchResult> matches(ServerWebExchange exchange) {
OrServerWebExchangeMatcher matcher = new OrServerWebExchangeMatcher(getDelegateMatchers()); return new OrServerWebExchangeMatcher(getDelegateMatchers().toList()).matches(exchange);
return matcher.matches(exchange); }
private Stream<ServerWebExchangeMatcher> getDelegateMatchers() {
return getPatterns().map(PathPatternParserServerWebExchangeMatcher::new);
} }
} }

View File

@ -23,7 +23,6 @@ import java.security.interfaces.RSAPrivateKey;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.AssertingParty; import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.AssertingParty;
@ -64,7 +63,7 @@ class Saml2RelyingPartyRegistrationConfiguration {
@Bean @Bean
RelyingPartyRegistrationRepository relyingPartyRegistrationRepository(Saml2RelyingPartyProperties properties) { RelyingPartyRegistrationRepository relyingPartyRegistrationRepository(Saml2RelyingPartyProperties properties) {
List<RelyingPartyRegistration> registrations = properties.getRegistration().entrySet().stream() List<RelyingPartyRegistration> registrations = properties.getRegistration().entrySet().stream()
.map(this::asRegistration).collect(Collectors.toList()); .map(this::asRegistration).toList();
return new InMemoryRelyingPartyRegistrationRepository(registrations); return new InMemoryRelyingPartyRegistrationRepository(registrations);
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.EnumSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
@ -134,11 +132,11 @@ public final class StaticResourceRequest {
@Override @Override
protected void initialized(Supplier<DispatcherServletPath> dispatcherServletPath) { protected void initialized(Supplier<DispatcherServletPath> dispatcherServletPath) {
this.delegate = new OrRequestMatcher(getDelegateMatchers(dispatcherServletPath.get())); this.delegate = new OrRequestMatcher(getDelegateMatchers(dispatcherServletPath.get()).toList());
} }
private List<RequestMatcher> getDelegateMatchers(DispatcherServletPath dispatcherServletPath) { private Stream<RequestMatcher> getDelegateMatchers(DispatcherServletPath dispatcherServletPath) {
return getPatterns(dispatcherServletPath).map(AntPathRequestMatcher::new).collect(Collectors.toList()); return getPatterns(dispatcherServletPath).map(AntPathRequestMatcher::new);
} }
private Stream<String> getPatterns(DispatcherServletPath dispatcherServletPath) { private Stream<String> getPatterns(DispatcherServletPath dispatcherServletPath) {

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.transaction; package org.springframework.boot.autoconfigure.transaction;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -58,7 +56,7 @@ public class TransactionAutoConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public TransactionManagerCustomizers platformTransactionManagerCustomizers( public TransactionManagerCustomizers platformTransactionManagerCustomizers(
ObjectProvider<PlatformTransactionManagerCustomizer<?>> customizers) { ObjectProvider<PlatformTransactionManagerCustomizer<?>> customizers) {
return new TransactionManagerCustomizers(customizers.orderedStream().collect(Collectors.toList())); return new TransactionManagerCustomizers(customizers.orderedStream().toList());
} }
@Bean @Bean

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.autoconfigure.web.client;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -58,9 +56,8 @@ public class RestTemplateAutoConfiguration {
ObjectProvider<RestTemplateRequestCustomizer<?>> restTemplateRequestCustomizers) { ObjectProvider<RestTemplateRequestCustomizer<?>> restTemplateRequestCustomizers) {
RestTemplateBuilderConfigurer configurer = new RestTemplateBuilderConfigurer(); RestTemplateBuilderConfigurer configurer = new RestTemplateBuilderConfigurer();
configurer.setHttpMessageConverters(messageConverters.getIfUnique()); configurer.setHttpMessageConverters(messageConverters.getIfUnique());
configurer.setRestTemplateCustomizers(restTemplateCustomizers.orderedStream().collect(Collectors.toList())); configurer.setRestTemplateCustomizers(restTemplateCustomizers.orderedStream().toList());
configurer.setRestTemplateRequestCustomizers( configurer.setRestTemplateRequestCustomizers(restTemplateRequestCustomizers.orderedStream().toList());
restTemplateRequestCustomizers.orderedStream().collect(Collectors.toList()));
return configurer; return configurer;
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; package org.springframework.boot.autoconfigure.web.reactive;
import java.util.stream.Collectors;
import io.undertow.Undertow; import io.undertow.Undertow;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import reactor.netty.http.server.HttpServer; import reactor.netty.http.server.HttpServer;
@ -71,7 +69,7 @@ abstract class ReactiveWebServerFactoryConfiguration {
NettyReactiveWebServerFactory serverFactory = new NettyReactiveWebServerFactory(); NettyReactiveWebServerFactory serverFactory = new NettyReactiveWebServerFactory();
serverFactory.setResourceFactory(resourceFactory); serverFactory.setResourceFactory(resourceFactory);
routes.orderedStream().forEach(serverFactory::addRouteProviders); routes.orderedStream().forEach(serverFactory::addRouteProviders);
serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().collect(Collectors.toList())); serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().toList());
return serverFactory; return serverFactory;
} }
@ -88,12 +86,9 @@ abstract class ReactiveWebServerFactoryConfiguration {
ObjectProvider<TomcatContextCustomizer> contextCustomizers, ObjectProvider<TomcatContextCustomizer> contextCustomizers,
ObjectProvider<TomcatProtocolHandlerCustomizer<?>> protocolHandlerCustomizers) { ObjectProvider<TomcatProtocolHandlerCustomizer<?>> protocolHandlerCustomizers) {
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory(); TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory();
factory.getTomcatConnectorCustomizers() factory.getTomcatConnectorCustomizers().addAll(connectorCustomizers.orderedStream().toList());
.addAll(connectorCustomizers.orderedStream().collect(Collectors.toList())); factory.getTomcatContextCustomizers().addAll(contextCustomizers.orderedStream().toList());
factory.getTomcatContextCustomizers() factory.getTomcatProtocolHandlerCustomizers().addAll(protocolHandlerCustomizers.orderedStream().toList());
.addAll(contextCustomizers.orderedStream().collect(Collectors.toList()));
factory.getTomcatProtocolHandlerCustomizers()
.addAll(protocolHandlerCustomizers.orderedStream().collect(Collectors.toList()));
return factory; return factory;
} }
@ -114,7 +109,7 @@ abstract class ReactiveWebServerFactoryConfiguration {
JettyReactiveWebServerFactory jettyReactiveWebServerFactory(JettyResourceFactory resourceFactory, JettyReactiveWebServerFactory jettyReactiveWebServerFactory(JettyResourceFactory resourceFactory,
ObjectProvider<JettyServerCustomizer> serverCustomizers) { ObjectProvider<JettyServerCustomizer> serverCustomizers) {
JettyReactiveWebServerFactory serverFactory = new JettyReactiveWebServerFactory(); JettyReactiveWebServerFactory serverFactory = new JettyReactiveWebServerFactory();
serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().collect(Collectors.toList())); serverFactory.getServerCustomizers().addAll(serverCustomizers.orderedStream().toList());
serverFactory.setResourceFactory(resourceFactory); serverFactory.setResourceFactory(resourceFactory);
return serverFactory; return serverFactory;
} }
@ -130,7 +125,7 @@ abstract class ReactiveWebServerFactoryConfiguration {
UndertowReactiveWebServerFactory undertowReactiveWebServerFactory( UndertowReactiveWebServerFactory undertowReactiveWebServerFactory(
ObjectProvider<UndertowBuilderCustomizer> builderCustomizers) { ObjectProvider<UndertowBuilderCustomizer> builderCustomizers) {
UndertowReactiveWebServerFactory factory = new UndertowReactiveWebServerFactory(); UndertowReactiveWebServerFactory factory = new UndertowReactiveWebServerFactory();
factory.getBuilderCustomizers().addAll(builderCustomizers.orderedStream().collect(Collectors.toList())); factory.getBuilderCustomizers().addAll(builderCustomizers.orderedStream().toList());
return factory; return factory;
} }

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.web.reactive.error; package org.springframework.boot.autoconfigure.web.reactive.error;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -67,7 +65,7 @@ public class ErrorWebFluxAutoConfiguration {
ServerCodecConfigurer serverCodecConfigurer, ApplicationContext applicationContext) { ServerCodecConfigurer serverCodecConfigurer, ApplicationContext applicationContext) {
DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes,
webProperties.getResources(), this.serverProperties.getError(), applicationContext); webProperties.getResources(), this.serverProperties.getError(), applicationContext);
exceptionHandler.setViewResolvers(viewResolvers.orderedStream().collect(Collectors.toList())); exceptionHandler.setViewResolvers(viewResolvers.orderedStream().toList());
exceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters()); exceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
exceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders()); exceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());
return exceptionHandler; return exceptionHandler;

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.web.reactive.function.client; package org.springframework.boot.autoconfigure.web.reactive.function.client;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -65,7 +63,7 @@ public class WebClientAutoConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
@Order(0) @Order(0)
public WebClientCodecCustomizer exchangeStrategiesCustomizer(ObjectProvider<CodecCustomizer> codecCustomizers) { public WebClientCodecCustomizer exchangeStrategiesCustomizer(ObjectProvider<CodecCustomizer> codecCustomizers) {
return new WebClientCodecCustomizer(codecCustomizers.orderedStream().collect(Collectors.toList())); return new WebClientCodecCustomizer(codecCustomizers.orderedStream().toList());
} }
} }

Some files were not shown because too many files have changed in this diff Show More