Use Map.forEach instead of manual Map.Entry iteration wherever possible SPR-16646
This commit is contained in:
committed by
Juergen Hoeller
parent
224d52e032
commit
4aae6a6dda
@@ -84,12 +84,11 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||
|
||||
HttpHeaders headersToUse = new HttpHeaders();
|
||||
if (headers != null) {
|
||||
for (String header : headers.keySet()) {
|
||||
List<String> values = headers.get(header);
|
||||
headers.forEach((header, values) -> {
|
||||
if (values != null && !specialHeaders.contains(header.toLowerCase())) {
|
||||
headersToUse.put(header, values);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
List<String> subProtocols =
|
||||
|
||||
@@ -147,9 +147,7 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
|
||||
request.addExtensions(new WebSocketToJettyExtensionConfigAdapter(e));
|
||||
}
|
||||
|
||||
for (String header : headers.keySet()) {
|
||||
request.setHeader(header, headers.get(header));
|
||||
}
|
||||
headers.forEach(request::setHeader);
|
||||
|
||||
Principal user = getUser();
|
||||
final JettyWebSocketSession wsSession = new JettyWebSocketSession(attributes, user);
|
||||
|
||||
@@ -153,21 +153,21 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
|
||||
M mappings = createMappings();
|
||||
if (this.sockJsServiceRegistration != null) {
|
||||
SockJsService sockJsService = this.sockJsServiceRegistration.getSockJsService();
|
||||
for (WebSocketHandler wsHandler : this.handlerMap.keySet()) {
|
||||
for (String path : this.handlerMap.get(wsHandler)) {
|
||||
this.handlerMap.forEach((wsHandler, paths) -> {
|
||||
for (String path : paths) {
|
||||
String pathPattern = (path.endsWith("/") ? path + "**" : path + "/**");
|
||||
addSockJsServiceMapping(mappings, sockJsService, wsHandler, pathPattern);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
HandshakeHandler handshakeHandler = getOrCreateHandshakeHandler();
|
||||
HandshakeInterceptor[] interceptors = getInterceptors();
|
||||
for (WebSocketHandler wsHandler : this.handlerMap.keySet()) {
|
||||
for (String path : this.handlerMap.get(wsHandler)) {
|
||||
this.handlerMap.forEach((wsHandler, paths) -> {
|
||||
for (String path : paths) {
|
||||
addWebSocketHandlerMapping(mappings, wsHandler, handshakeHandler, interceptors, path);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return mappings;
|
||||
|
||||
@@ -127,11 +127,11 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
|
||||
for (ServletWebSocketHandlerRegistration registration : this.registrations) {
|
||||
updateTaskScheduler(registration);
|
||||
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
|
||||
for (HttpRequestHandler httpHandler : mappings.keySet()) {
|
||||
for (String pattern : mappings.get(httpHandler)) {
|
||||
mappings.forEach((httpHandler, patterns) -> {
|
||||
for (String pattern : patterns) {
|
||||
urlMap.put(pattern, httpHandler);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
|
||||
hm.setUrlMap(urlMap);
|
||||
|
||||
@@ -150,11 +150,11 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
||||
Map<String, Object> urlMap = new LinkedHashMap<>();
|
||||
for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
|
||||
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
|
||||
for (HttpRequestHandler httpHandler : mappings.keySet()) {
|
||||
for (String pattern : mappings.get(httpHandler)) {
|
||||
mappings.forEach((httpHandler, patterns) -> {
|
||||
for (String pattern : patterns) {
|
||||
urlMap.put(pattern, httpHandler);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
|
||||
hm.setUrlMap(urlMap);
|
||||
|
||||
@@ -184,9 +184,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
||||
.secure(request.isSecure())
|
||||
.remoteAddr(request.getRemoteAddr())
|
||||
.build();
|
||||
for (String header : headers.keySet()) {
|
||||
context.getHeaders().put(header, headers.get(header));
|
||||
}
|
||||
headers.forEach((header, value) -> context.getHeaders().put(header, value));
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user