Replace Collectors.toList with Stream.toList
Closes gh-29203
This commit is contained in:
committed by
Brian Clozel
parent
9d263668d5
commit
0ccb64fe10
@@ -486,7 +486,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
range.getWeight() == Locale.LanguageRange.MAX_WEIGHT ?
|
||||
range.getRange() :
|
||||
range.getRange() + ";q=" + decimal.format(range.getWeight()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
set(ACCEPT_LANGUAGE, toCommaDelimitedString(values));
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
public void setAcceptLanguageAsLocales(List<Locale> locales) {
|
||||
setAcceptLanguage(locales.stream()
|
||||
.map(locale -> new Locale.LanguageRange(locale.toLanguageTag()))
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,7 +529,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
return ranges.stream()
|
||||
.map(range -> Locale.forLanguageTag(range.getRange()))
|
||||
.filter(locale -> StringUtils.hasText(locale.getDisplayName()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -149,7 +148,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
|
||||
}
|
||||
|
||||
List<? extends Publisher<Void>> actions = this.commitActions.stream()
|
||||
.map(Supplier::get).collect(Collectors.toList());
|
||||
.map(Supplier::get).toList();
|
||||
|
||||
return Flux.concat(actions).then();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@@ -177,7 +176,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
return this.headers.getFieldNamesCollection().stream()
|
||||
.map(this.headers::getValuesList).collect(Collectors.toList());
|
||||
.map(this.headers::getValuesList).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.netty5.handler.codec.http.HttpHeaders;
|
||||
|
||||
@@ -165,7 +164,7 @@ class Netty5HeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
return this.headers.names().stream()
|
||||
.map(this.headers::getAll).collect(Collectors.toList());
|
||||
.map(this.headers::getAll).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
@@ -164,7 +163,7 @@ class NettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
return this.headers.names().stream()
|
||||
.map(this.headers::getAll).collect(Collectors.toList());
|
||||
.map(this.headers::getAll).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import org.reactivestreams.Publisher;
|
||||
@@ -61,7 +60,7 @@ public class ProtobufEncoder extends ProtobufCodecSupport implements HttpMessage
|
||||
.stream()
|
||||
.map(mimeType -> new MediaType(mimeType.getType(), mimeType.getSubtype(),
|
||||
Collections.singletonMap(DELIMITED_KEY, DELIMITED_VALUE)))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@@ -161,7 +160,7 @@ class JettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
return this.headers.getFieldNamesCollection().stream()
|
||||
.map(this.headers::getValuesList).collect(Collectors.toList());
|
||||
.map(this.headers::getValuesList).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.netty5.handler.codec.http.HttpHeaders;
|
||||
|
||||
@@ -163,7 +162,7 @@ final class Netty5HeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
return this.headers.names().stream()
|
||||
.map(this.headers::getAll).collect(Collectors.toList());
|
||||
.map(this.headers::getAll).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
@@ -163,7 +162,7 @@ final class NettyHeadersAdapter implements MultiValueMap<String, String> {
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
return this.headers.names().stream()
|
||||
.map(this.headers::getAll).collect(Collectors.toList());
|
||||
.map(this.headers::getAll).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.tomcat.util.buf.MessageBytes;
|
||||
import org.apache.tomcat.util.http.MimeHeaders;
|
||||
@@ -172,7 +171,7 @@ class TomcatHeadersAdapter implements MultiValueMap<String, String> {
|
||||
|
||||
@Override
|
||||
public Collection<List<String>> values() {
|
||||
return keySet().stream().map(this::get).collect(Collectors.toList());
|
||||
return keySet().stream().map(this::get).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.web.bind.support;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -124,7 +123,7 @@ public class WebExchangeDataBinder extends WebDataBinder {
|
||||
if (!CollectionUtils.isEmpty(values)) {
|
||||
values = values.stream()
|
||||
.map(value -> value instanceof FormFieldPart ? ((FormFieldPart) value).value() : value)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
params.put(key, values.size() == 1 ? values.get(0) : values);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import io.micrometer.observation.Observation;
|
||||
@@ -971,7 +970,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
.filter(converter -> canReadResponse(this.responseType, converter))
|
||||
.flatMap((HttpMessageConverter<?> converter) -> getSupportedMediaTypes(this.responseType, converter))
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
MimeTypeUtils.sortBySpecificity(allSupportedMediaTypes);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Accept=" + allSupportedMediaTypes);
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -136,7 +135,7 @@ public class CorsConfiguration {
|
||||
*/
|
||||
public void setAllowedOrigins(@Nullable List<String> origins) {
|
||||
this.allowedOrigins = (origins == null ? null :
|
||||
origins.stream().filter(Objects::nonNull).map(this::trimTrailingSlash).collect(Collectors.toList()));
|
||||
origins.stream().filter(Objects::nonNull).map(this::trimTrailingSlash).toList());
|
||||
}
|
||||
|
||||
private String trimTrailingSlash(String origin) {
|
||||
@@ -212,7 +211,7 @@ public class CorsConfiguration {
|
||||
}
|
||||
return this.allowedOriginPatterns.stream()
|
||||
.map(OriginPattern::getDeclaredPattern)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,7 +444,7 @@ public class CorsConfiguration {
|
||||
if (this.allowedMethods == null) {
|
||||
this.allowedMethods = DEFAULT_PERMIT_METHODS;
|
||||
this.resolvedMethods = DEFAULT_PERMIT_METHODS
|
||||
.stream().map(HttpMethod::valueOf).collect(Collectors.toList());
|
||||
.stream().map(HttpMethod::valueOf).toList();
|
||||
}
|
||||
if (this.allowedHeaders == null) {
|
||||
this.allowedHeaders = DEFAULT_PERMIT_ALL;
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import reactor.blockhound.BlockHound;
|
||||
import reactor.blockhound.integration.BlockHoundIntegration;
|
||||
@@ -170,13 +169,13 @@ public final class WebHttpHandlerBuilder {
|
||||
List<WebFilter> webFilters = context
|
||||
.getBeanProvider(WebFilter.class)
|
||||
.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
builder.filters(filters -> filters.addAll(webFilters));
|
||||
|
||||
List<WebExceptionHandler> exceptionHandlers = context
|
||||
.getBeanProvider(WebExceptionHandler.class)
|
||||
.orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
builder.exceptionHandlers(handlers -> handlers.addAll(exceptionHandlers));
|
||||
|
||||
context.getBeanProvider(HttpHandlerDecoratorFactory.class)
|
||||
@@ -253,7 +252,7 @@ public final class WebHttpHandlerBuilder {
|
||||
}
|
||||
})
|
||||
.filter(filter -> !(filter instanceof ForwardedHeaderTransformer))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
this.filters.clear();
|
||||
this.filters.addAll(filtersToUse);
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
@@ -100,7 +99,7 @@ public class CookieWebSessionIdResolver implements WebSessionIdResolver {
|
||||
if (cookies == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return cookies.stream().map(HttpCookie::getValue).collect(Collectors.toList());
|
||||
return cookies.stream().map(HttpCookie::getValue).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user