Use Map.forEach instead of manual Map.Entry iteration wherever possible
Issue: SPR-16646
This commit is contained in:
@@ -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.
|
||||
@@ -119,12 +119,7 @@ public class WebSocketExtension {
|
||||
public String toString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(this.name);
|
||||
for (Map.Entry<String, String> entry : this.parameters.entrySet()) {
|
||||
str.append(';');
|
||||
str.append(entry.getKey());
|
||||
str.append('=');
|
||||
str.append(entry.getValue());
|
||||
}
|
||||
this.parameters.forEach((key, value) -> str.append(';').append(key).append('=').append(value));
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.socket.adapter.jetty;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
|
||||
import org.springframework.web.socket.WebSocketExtension;
|
||||
@@ -30,8 +28,7 @@ public class WebSocketToJettyExtensionConfigAdapter extends ExtensionConfig {
|
||||
|
||||
public WebSocketToJettyExtensionConfigAdapter(WebSocketExtension extension) {
|
||||
super(extension.getName());
|
||||
for (Map.Entry<String,String> p : extension.getParameters().entrySet()) {
|
||||
super.setParameter(p.getKey(), p.getValue());
|
||||
}
|
||||
extension.getParameters().forEach(super::setParameter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -18,8 +18,6 @@ package org.springframework.web.socket.server.standard;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -67,9 +65,7 @@ public class GlassFishRequestUpgradeStrategy extends AbstractTyrusRequestUpgrade
|
||||
handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);
|
||||
|
||||
response.setStatus(upgradeResponse.getStatus());
|
||||
for (Map.Entry<String, List<String>> entry : upgradeResponse.getHeaders().entrySet()) {
|
||||
response.addHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
|
||||
}
|
||||
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
|
||||
response.flushBuffer();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ package org.springframework.web.socket.server.standard;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
@@ -63,9 +61,7 @@ public class WebLogicRequestUpgradeStrategy extends AbstractTyrusRequestUpgradeS
|
||||
UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
|
||||
|
||||
response.setStatus(upgradeResponse.getStatus());
|
||||
for (Map.Entry<String, List<String>> entry : upgradeResponse.getHeaders().entrySet()) {
|
||||
response.addHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
|
||||
}
|
||||
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
|
||||
|
||||
AsyncContext asyncContext = request.startAsync();
|
||||
asyncContext.setTimeout(-1L);
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
@@ -161,11 +159,11 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
|
||||
|
||||
|
||||
private static void addHttpHeaders(Request request, HttpHeaders headers) {
|
||||
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
|
||||
for (String value : entry.getValue()) {
|
||||
request.header(entry.getKey(), value);
|
||||
headers.forEach((key, values) -> {
|
||||
for (String value : values) {
|
||||
request.header(key, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static HttpHeaders toHttpHeaders(HttpFields httpFields) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
@@ -171,11 +170,11 @@ public class UndertowXhrTransport extends AbstractXhrTransport {
|
||||
|
||||
private static void addHttpHeaders(ClientRequest request, HttpHeaders headers) {
|
||||
HeaderMap headerMap = request.getRequestHeaders();
|
||||
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
|
||||
for (String value : entry.getValue()) {
|
||||
headerMap.add(HttpString.tryFromString(entry.getKey()), value);
|
||||
headers.forEach((key, values) -> {
|
||||
for (String value : values) {
|
||||
headerMap.add(HttpString.tryFromString(key), value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ClientCallback<ClientExchange> createReceiveCallback(final TransportRequest transportRequest,
|
||||
|
||||
Reference in New Issue
Block a user