Use Map.forEach instead of manual Map.Entry iteration wherever possible

Issue: SPR-16646
This commit is contained in:
Juergen Hoeller
2018-03-27 00:38:32 +02:00
parent 10cb2ccaef
commit e3d0ef6015
50 changed files with 231 additions and 366 deletions

View File

@@ -416,12 +416,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
private HttpHeaders(Map<String, List<String>> headers, boolean readOnly) {
Assert.notNull(headers, "'headers' must not be null");
if (readOnly) {
Map<String, List<String>> map =
new LinkedCaseInsensitiveMap<>(headers.size(), Locale.ENGLISH);
for (Entry<String, List<String>> entry : headers.entrySet()) {
List<String> values = Collections.unmodifiableList(entry.getValue());
map.put(entry.getKey(), values);
}
Map<String, List<String>> map = new LinkedCaseInsensitiveMap<>(headers.size(), Locale.ENGLISH);
headers.forEach((key, valueList) -> map.put(key, Collections.unmodifiableList(valueList)));
this.headers = Collections.unmodifiableMap(map);
}
else {
@@ -1438,9 +1434,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@Override
public void addAll(MultiValueMap<String, String> values) {
for (Entry<String, List<String>> entry : values.entrySet()) {
addAll(entry.getKey(), entry.getValue());
}
values.forEach(this::addAll);
}
/**
@@ -1460,17 +1454,13 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@Override
public void setAll(Map<String, String> values) {
for (Entry<String, String> entry : values.entrySet()) {
set(entry.getKey(), entry.getValue());
}
values.forEach(this::set);
}
@Override
public Map<String, String> toSingleValueMap() {
LinkedHashMap<String, String> singleValueMap = new LinkedHashMap<>(this.headers.size());
for (Entry<String, List<String>> entry : this.headers.entrySet()) {
singleValueMap.put(entry.getKey(), entry.getValue().get(0));
}
this.headers.forEach((key, valueList) -> singleValueMap.put(key, valueList.get(0)));
return singleValueMap;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,6 @@ package org.springframework.http.client;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
@@ -97,19 +95,18 @@ final class HttpComponentsClientHttpRequest extends AbstractBufferingClientHttpR
* @param headers the headers to add
*/
static void addHeaders(HttpUriRequest httpRequest, HttpHeaders headers) {
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String headerName = entry.getKey();
headers.forEach((headerName, headerValues) -> {
if (HttpHeaders.COOKIE.equalsIgnoreCase(headerName)) { // RFC 6265
String headerValue = StringUtils.collectionToDelimitedString(entry.getValue(), "; ");
String headerValue = StringUtils.collectionToDelimitedString(headerValues, "; ");
httpRequest.addHeader(headerName, headerValue);
}
else if (!HTTP.CONTENT_LEN.equalsIgnoreCase(headerName) &&
!HTTP.TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {
for (String headerValue : entry.getValue()) {
for (String headerValue : headerValues) {
httpRequest.addHeader(headerName, headerValue);
}
}
}
});
}
}

View File

@@ -19,8 +19,6 @@ package org.springframework.http.client;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import io.netty.bootstrap.Bootstrap;
@@ -142,9 +140,7 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements
nettyRequest.headers().set(HttpHeaders.HOST, this.uri.getHost() + ":" + getPort(uri));
nettyRequest.headers().set(HttpHeaders.CONNECTION, "close");
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
nettyRequest.headers().add(entry.getKey(), entry.getValue());
}
headers.forEach((headerName, headerValues) -> nettyRequest.headers().add(headerName, headerValues));
if (!nettyRequest.headers().contains(HttpHeaders.CONTENT_LENGTH) && this.body.buffer().readableBytes() > 0) {
nettyRequest.headers().set(HttpHeaders.CONTENT_LENGTH, this.body.buffer().readableBytes());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@ package org.springframework.http.client;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
@@ -137,12 +135,11 @@ public class OkHttp3ClientHttpRequestFactory
RequestBody.create(contentType, content) : null);
Request.Builder builder = new Request.Builder().url(uri.toURL()).method(method.name(), body);
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String headerName = entry.getKey();
for (String headerValue : entry.getValue()) {
headers.forEach((headerName, headerValues) -> {
for (String headerValue : headerValues) {
builder.addHeader(headerName, headerValue);
}
}
});
return builder.build();
}

View File

@@ -20,8 +20,6 @@ import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -93,19 +91,18 @@ final class SimpleBufferingClientHttpRequest extends AbstractBufferingClientHttp
* @param headers the headers to add
*/
static void addHeaders(HttpURLConnection connection, HttpHeaders headers) {
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String headerName = entry.getKey();
headers.forEach((headerName, headerValues) -> {
if (HttpHeaders.COOKIE.equalsIgnoreCase(headerName)) { // RFC 6265
String headerValue = StringUtils.collectionToDelimitedString(entry.getValue(), "; ");
String headerValue = StringUtils.collectionToDelimitedString(headerValues, "; ");
connection.setRequestProperty(headerName, headerValue);
}
else {
for (String headerValue : entry.getValue()) {
for (String headerValue : headerValues) {
String actualHeaderValue = headerValue != null ? headerValue : "";
connection.addRequestProperty(headerName, actualHeaderValue);
}
}
}
});
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpHeaders;
@@ -99,12 +98,11 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
private void writeHeaders() {
if (!this.headersWritten) {
for (Map.Entry<String, List<String>> entry : this.headers.entrySet()) {
String headerName = entry.getKey();
for (String headerValue : entry.getValue()) {
getHeaders().forEach((headerName, headerValues) -> {
for (String headerValue : headerValues) {
this.servletResponse.addHeader(headerName, headerValue);
}
}
});
// HttpServletResponse exposes some headers as properties: we should include those if not already present
if (this.servletResponse.getContentType() == null && this.headers.getContentType() != null) {
this.servletResponse.setContentType(this.headers.getContentType().toString());

View File

@@ -20,8 +20,6 @@ import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import reactor.core.publisher.Flux;
@@ -80,14 +78,8 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
this.originalRequest = original;
}
private static <K, V> void copyMultiValueMap(MultiValueMap<K,V> source,
MultiValueMap<K,V> destination) {
for (Map.Entry<K, List<V>> entry : source.entrySet()) {
K key = entry.getKey();
List<V> values = new LinkedList<>(entry.getValue());
destination.put(key, values);
}
private static <K, V> void copyMultiValueMap(MultiValueMap<K,V> source, MultiValueMap<K,V> target) {
source.forEach((key, value) -> target.put(key, new LinkedList<>(value)));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,6 @@
package org.springframework.http.server.reactive;
import java.io.File;
import java.util.List;
import java.util.Map;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.HttpResponseStatus;
@@ -85,11 +83,11 @@ class ReactorServerHttpResponse extends AbstractServerHttpResponse implements Ze
@Override
protected void applyHeaders() {
for (Map.Entry<String, List<String>> entry : getHeaders().entrySet()) {
for (String value : entry.getValue()) {
this.response.responseHeaders().add(entry.getKey(), value);
getHeaders().forEach((headerName, headerValues) -> {
for (String value : headerValues) {
this.response.responseHeaders().add(headerName, value);
}
}
});
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@ package org.springframework.http.server.reactive;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent;
import javax.servlet.AsyncListener;
@@ -99,12 +97,11 @@ class ServletServerHttpResponse extends AbstractListenerServerHttpResponse {
@Override
protected void applyHeaders() {
for (Map.Entry<String, List<String>> entry : getHeaders().entrySet()) {
String headerName = entry.getKey();
for (String headerValue : entry.getValue()) {
getHeaders().forEach((headerName, headerValues) -> {
for (String headerValue : headerValues) {
this.response.addHeader(headerName, headerValue);
}
}
});
MediaType contentType = getHeaders().getContentType();
if (this.response.getContentType() == null && contentType != null) {
this.response.setContentType(contentType.toString());

View File

@@ -21,8 +21,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.Map;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.Cookie;
@@ -82,10 +80,8 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl
@Override
protected void applyHeaders() {
for (Map.Entry<String, List<String>> entry : getHeaders().entrySet()) {
HttpString headerName = HttpString.tryFromString(entry.getKey());
this.exchange.getResponseHeaders().addAll(headerName, entry.getValue());
}
getHeaders().forEach((headerName, headerValues) ->
this.exchange.getResponseHeaders().addAll(HttpString.tryFromString(headerName), headerValues));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import javax.servlet.ServletContext;
@@ -160,11 +159,11 @@ public class ContentNegotiationManagerFactoryBean
*/
public void setMediaTypes(Properties mediaTypes) {
if (!CollectionUtils.isEmpty(mediaTypes)) {
for (Entry<Object, Object> entry : mediaTypes.entrySet()) {
String extension = ((String)entry.getKey()).toLowerCase(Locale.ENGLISH);
MediaType mediaType = MediaType.valueOf((String) entry.getValue());
mediaTypes.forEach((key, value) -> {
String extension = ((String) key).toLowerCase(Locale.ENGLISH);
MediaType mediaType = MediaType.valueOf((String) value);
this.mediaTypes.put(extension, mediaType);
}
});
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -43,11 +42,9 @@ import org.springframework.util.MultiValueMap;
*/
public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExtensionResolver {
private final ConcurrentMap<String, MediaType> mediaTypes =
new ConcurrentHashMap<>(64);
private final ConcurrentMap<String, MediaType> mediaTypes = new ConcurrentHashMap<>(64);
private final MultiValueMap<MediaType, String> fileExtensions =
new LinkedMultiValueMap<>();
private final MultiValueMap<MediaType, String> fileExtensions = new LinkedMultiValueMap<>();
private final List<String> allFileExtensions = new LinkedList<>();
@@ -57,13 +54,12 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
*/
public MappingMediaTypeFileExtensionResolver(@Nullable Map<String, MediaType> mediaTypes) {
if (mediaTypes != null) {
for (Entry<String, MediaType> entries : mediaTypes.entrySet()) {
String extension = entries.getKey().toLowerCase(Locale.ENGLISH);
MediaType mediaType = entries.getValue();
this.mediaTypes.put(extension, mediaType);
this.fileExtensions.add(mediaType, extension);
this.allFileExtensions.add(extension);
}
mediaTypes.forEach((extension, mediaType) -> {
String lowerCaseExtension = extension.toLowerCase(Locale.ENGLISH);
this.mediaTypes.put(lowerCaseExtension, mediaType);
this.fileExtensions.add(mediaType, lowerCaseExtension);
this.allFileExtensions.add(lowerCaseExtension);
});
}
}
@@ -91,7 +87,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
@Override
public List<String> resolveFileExtensions(MediaType mediaType) {
List<String> fileExtensions = this.fileExtensions.get(mediaType);
return (fileExtensions != null) ? fileExtensions : Collections.emptyList();
return (fileExtensions != null ? fileExtensions : Collections.emptyList());
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -315,9 +315,7 @@ public class WebDataBinder extends DataBinder {
* @see #setBindEmptyMultipartFiles
*/
protected void bindMultipart(Map<String, List<MultipartFile>> multipartFiles, MutablePropertyValues mpvs) {
for (Map.Entry<String, List<MultipartFile>> entry : multipartFiles.entrySet()) {
String key = entry.getKey();
List<MultipartFile> values = entry.getValue();
multipartFiles.forEach((key, values) -> {
if (values.size() == 1) {
MultipartFile value = values.get(0);
if (isBindEmptyMultipartFiles() || !value.isEmpty()) {
@@ -327,7 +325,7 @@ public class WebDataBinder extends DataBinder {
else {
mpvs.add(key, values);
}
}
});
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
package org.springframework.web.bind.support;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Part;
@@ -141,17 +139,17 @@ public class WebRequestDataBinder extends WebDataBinder {
for (Part part : request.getParts()) {
map.add(part.getName(), part);
}
for (Map.Entry<String, List<Part>> entry: map.entrySet()) {
if (entry.getValue().size() == 1) {
Part part = entry.getValue().get(0);
map.forEach((key, values) -> {
if (values.size() == 1) {
Part part = values.get(0);
if (isBindEmptyMultipartFiles() || part.getSize() > 0) {
mpvs.add(entry.getKey(), part);
mpvs.add(key, part);
}
}
else {
mpvs.add(entry.getKey(), entry.getValue());
mpvs.add(key, values);
}
}
});
}
catch (Exception ex) {
throw new MultipartException("Failed to get request parts", ex);

View File

@@ -912,9 +912,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
HttpHeaders httpHeaders = httpRequest.getHeaders();
HttpHeaders requestHeaders = this.requestEntity.getHeaders();
if (!requestHeaders.isEmpty()) {
for (Map.Entry<String, List<String>> entry : requestHeaders.entrySet()) {
httpHeaders.put(entry.getKey(), new LinkedList<>(entry.getValue()));
}
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new LinkedList<>(values)));
}
if (httpHeaders.getContentLength() < 0) {
httpHeaders.setContentLength(0L);
@@ -933,9 +931,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
(GenericHttpMessageConverter<Object>) messageConverter;
if (genericConverter.canWrite(requestBodyType, requestBodyClass, requestContentType)) {
if (!requestHeaders.isEmpty()) {
for (Map.Entry<String, List<String>> entry : requestHeaders.entrySet()) {
httpHeaders.put(entry.getKey(), new LinkedList<>(entry.getValue()));
}
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new LinkedList<>(values)));
}
if (logger.isDebugEnabled()) {
if (requestContentType != null) {
@@ -953,9 +949,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
else if (messageConverter.canWrite(requestBodyClass, requestContentType)) {
if (!requestHeaders.isEmpty()) {
for (Map.Entry<String, List<String>> entry : requestHeaders.entrySet()) {
httpHeaders.put(entry.getKey(), new LinkedList<>(entry.getValue()));
}
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new LinkedList<>(values)));
}
if (logger.isDebugEnabled()) {
if (requestContentType != null) {

View File

@@ -64,20 +64,20 @@ public class RequestParamMapMethodArgumentResolver implements HandlerMethodArgum
Map<String, String[]> parameterMap = webRequest.getParameterMap();
if (MultiValueMap.class.isAssignableFrom(paramType)) {
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(parameterMap.size());
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
for (String value : entry.getValue()) {
result.add(entry.getKey(), value);
parameterMap.forEach((key, values) -> {
for (String value : values) {
result.add(key, value);
}
}
});
return result;
}
else {
Map<String, String> result = new LinkedHashMap<>(parameterMap.size());
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
if (entry.getValue().length > 0) {
result.put(entry.getKey(), entry.getValue()[0]);
parameterMap.forEach((key, values) -> {
if (values.length > 0) {
result.put(key, values[0]);
}
}
});
return result;
}
}

View File

@@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
@@ -151,9 +150,7 @@ final class HierarchicalUriComponents extends UriComponents {
public String getQuery() {
if (!this.queryParams.isEmpty()) {
StringBuilder queryBuilder = new StringBuilder();
for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
String name = entry.getKey();
List<String> values = entry.getValue();
this.queryParams.forEach((name, values) -> {
if (CollectionUtils.isEmpty(values)) {
if (queryBuilder.length() != 0) {
queryBuilder.append('&');
@@ -171,7 +168,7 @@ final class HierarchicalUriComponents extends UriComponents {
}
}
}
}
});
return queryBuilder.toString();
}
else {
@@ -216,14 +213,14 @@ final class HierarchicalUriComponents extends UriComponents {
private MultiValueMap<String, String> encodeQueryParams(Charset charset) {
int size = this.queryParams.size();
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size);
for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
String name = encodeUriComponent(entry.getKey(), charset, Type.QUERY_PARAM);
List<String> values = new ArrayList<>(entry.getValue().size());
for (String value : entry.getValue()) {
values.add(encodeUriComponent(value, charset, Type.QUERY_PARAM));
this.queryParams.forEach((key, values) -> {
String name = encodeUriComponent(key, charset, Type.QUERY_PARAM);
List<String> encodedValues = new ArrayList<>(values.size());
for (String value : values) {
encodedValues.add(encodeUriComponent(value, charset, Type.QUERY_PARAM));
}
result.put(name, values);
}
result.put(name, encodedValues);
});
return result;
}
@@ -298,12 +295,12 @@ final class HierarchicalUriComponents extends UriComponents {
verifyUriComponent(this.userInfo, Type.USER_INFO);
verifyUriComponent(this.host, getHostType());
this.path.verify();
for (Map.Entry<String, List<String>> entry : queryParams.entrySet()) {
verifyUriComponent(entry.getKey(), Type.QUERY_PARAM);
for (String value : entry.getValue()) {
this.queryParams.forEach((key, values) -> {
verifyUriComponent(key, Type.QUERY_PARAM);
for (String value : values) {
verifyUriComponent(value, Type.QUERY_PARAM);
}
}
});
verifyUriComponent(getFragment(), Type.FRAGMENT);
}
@@ -360,15 +357,15 @@ final class HierarchicalUriComponents extends UriComponents {
private MultiValueMap<String, String> expandQueryParams(UriTemplateVariables variables) {
int size = this.queryParams.size();
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size);
variables = new QueryUriTemplateVariables(variables);
for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
String name = expandUriComponent(entry.getKey(), variables);
List<String> values = new ArrayList<>(entry.getValue().size());
for (String value : entry.getValue()) {
values.add(expandUriComponent(value, variables));
UriTemplateVariables queryVariables = new QueryUriTemplateVariables(variables);
this.queryParams.forEach((key, values) -> {
String name = expandUriComponent(key, queryVariables);
List<String> expandedValues = new ArrayList<>(values.size());
for (String value : values) {
expandedValues.add(expandUriComponent(value, queryVariables));
}
result.put(name, values);
}
result.put(name, expandedValues);
});
return result;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@ import java.net.URLDecoder;
import java.nio.charset.UnsupportedCharsetException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -544,9 +543,7 @@ public class UrlPathHelper {
}
else {
Map<String, String> decodedVars = new LinkedHashMap<>(vars.size());
for (Entry<String, String> entry : vars.entrySet()) {
decodedVars.put(entry.getKey(), decodeInternal(request, entry.getValue()));
}
vars.forEach((key, value) -> decodedVars.put(key, decodeInternal(request, value)));
return decodedVars;
}
}