Use Map.forEach instead of manual Map.Entry iteration wherever possible SPR-16646
This commit is contained in:
parent
224d52e032
commit
4aae6a6dda
|
|
@ -153,15 +153,15 @@ public class SimpleHttpServerFactoryBean implements FactoryBean<HttpServer>, Ini
|
||||||
this.server.setExecutor(this.executor);
|
this.server.setExecutor(this.executor);
|
||||||
}
|
}
|
||||||
if (this.contexts != null) {
|
if (this.contexts != null) {
|
||||||
for (String key : this.contexts.keySet()) {
|
this.contexts.forEach((key, context) -> {
|
||||||
HttpContext httpContext = this.server.createContext(key, this.contexts.get(key));
|
HttpContext httpContext = this.server.createContext(key, context);
|
||||||
if (this.filters != null) {
|
if (this.filters != null) {
|
||||||
httpContext.getFilters().addAll(this.filters);
|
httpContext.getFilters().addAll(this.filters);
|
||||||
}
|
}
|
||||||
if (this.authenticator != null) {
|
if (this.authenticator != null) {
|
||||||
httpContext.setAuthenticator(this.authenticator);
|
httpContext.setAuthenticator(this.authenticator);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
if (this.logger.isInfoEnabled()) {
|
if (this.logger.isInfoEnabled()) {
|
||||||
this.logger.info("Starting HttpServer at address " + address);
|
this.logger.info("Starting HttpServer at address " + address);
|
||||||
|
|
|
||||||
|
|
@ -196,8 +196,8 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
|
||||||
return allMatches;
|
return allMatches;
|
||||||
}
|
}
|
||||||
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(allMatches.size());
|
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(allMatches.size());
|
||||||
for (String sessionId : allMatches.keySet()) {
|
allMatches.forEach((sessionId, subIds) -> {
|
||||||
for (String subId : allMatches.get(sessionId)) {
|
for (String subId : subIds) {
|
||||||
SessionSubscriptionInfo info = this.subscriptionRegistry.getSubscriptions(sessionId);
|
SessionSubscriptionInfo info = this.subscriptionRegistry.getSubscriptions(sessionId);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -225,7 +225,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
|
||||||
logger.debug("Failed to evaluate selector", ex);
|
logger.debug("Failed to evaluate selector", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -526,8 +526,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||||
*/
|
*/
|
||||||
public void setParameters(Map<String, ?> params) {
|
public void setParameters(Map<String, ?> params) {
|
||||||
Assert.notNull(params, "Parameter map must not be null");
|
Assert.notNull(params, "Parameter map must not be null");
|
||||||
for (String key : params.keySet()) {
|
params.forEach((key, value) -> {
|
||||||
Object value = params.get(key);
|
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
setParameter(key, (String) value);
|
setParameter(key, (String) value);
|
||||||
}
|
}
|
||||||
|
|
@ -538,7 +537,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Parameter map value must be single value " + " or array of type [" + String.class.getName() + "]");
|
"Parameter map value must be single value " + " or array of type [" + String.class.getName() + "]");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -576,8 +575,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||||
*/
|
*/
|
||||||
public void addParameters(Map<String, ?> params) {
|
public void addParameters(Map<String, ?> params) {
|
||||||
Assert.notNull(params, "Parameter map must not be null");
|
Assert.notNull(params, "Parameter map must not be null");
|
||||||
for (String key : params.keySet()) {
|
params.forEach((key, value) -> {
|
||||||
Object value = params.get(key);
|
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
addParameter(key, (String) value);
|
addParameter(key, (String) value);
|
||||||
}
|
}
|
||||||
|
|
@ -588,7 +586,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||||
throw new IllegalArgumentException("Parameter map value must be single value " +
|
throw new IllegalArgumentException("Parameter map value must be single value " +
|
||||||
" or array of type [" + String.class.getName() + "]");
|
" or array of type [" + String.class.getName() + "]");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -118,14 +118,13 @@ public abstract class ModelAndViewAssert {
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (String modelName : model.keySet()) {
|
model.forEach((modelName, mavValue) -> {
|
||||||
Object assertionValue = expectedModel.get(modelName);
|
Object assertionValue = expectedModel.get(modelName);
|
||||||
Object mavValue = model.get(modelName);
|
|
||||||
if (!assertionValue.equals(mavValue)) {
|
if (!assertionValue.equals(mavValue)) {
|
||||||
sb.append("Value under name '").append(modelName).append("' differs, should have been '").append(
|
sb.append("Value under name '").append(modelName).append("' differs, should have been '").append(
|
||||||
assertionValue).append("' but was '").append(mavValue).append("'\n");
|
assertionValue).append("' but was '").append(mavValue).append("'\n");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (sb.length() != 0) {
|
if (sb.length() != 0) {
|
||||||
sb.insert(0, "Values of expected model do not match.\n");
|
sb.insert(0, "Values of expected model do not match.\n");
|
||||||
|
|
|
||||||
|
|
@ -345,11 +345,11 @@ public class MockHttpServletRequestBuilder
|
||||||
* @since 4.2.4
|
* @since 4.2.4
|
||||||
*/
|
*/
|
||||||
public MockHttpServletRequestBuilder params(MultiValueMap<String, String> params) {
|
public MockHttpServletRequestBuilder params(MultiValueMap<String, String> params) {
|
||||||
for (String name : params.keySet()) {
|
params.forEach((name, values) -> {
|
||||||
for (String value : params.get(name)) {
|
for (String value : values) {
|
||||||
this.parameters.add(name, value);
|
this.parameters.add(name, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -414,9 +414,7 @@ public class MockHttpServletRequestBuilder
|
||||||
*/
|
*/
|
||||||
public MockHttpServletRequestBuilder sessionAttrs(Map<String, Object> sessionAttributes) {
|
public MockHttpServletRequestBuilder sessionAttrs(Map<String, Object> sessionAttributes) {
|
||||||
Assert.notEmpty(sessionAttributes, "'sessionAttributes' must not be empty");
|
Assert.notEmpty(sessionAttributes, "'sessionAttributes' must not be empty");
|
||||||
for (String name : sessionAttributes.keySet()) {
|
sessionAttributes.forEach(this::sessionAttr);
|
||||||
sessionAttr(name, sessionAttributes.get(name));
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -436,9 +434,7 @@ public class MockHttpServletRequestBuilder
|
||||||
*/
|
*/
|
||||||
public MockHttpServletRequestBuilder flashAttrs(Map<String, Object> flashAttributes) {
|
public MockHttpServletRequestBuilder flashAttrs(Map<String, Object> flashAttributes) {
|
||||||
Assert.notEmpty(flashAttributes, "'flashAttributes' must not be empty");
|
Assert.notEmpty(flashAttributes, "'flashAttributes' must not be empty");
|
||||||
for (String name : flashAttributes.keySet()) {
|
flashAttributes.forEach(this::flashAttr);
|
||||||
flashAttr(name, flashAttributes.get(name));
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -624,22 +620,22 @@ public class MockHttpServletRequestBuilder
|
||||||
request.setContent(this.content);
|
request.setContent(this.content);
|
||||||
request.setContentType(this.contentType);
|
request.setContentType(this.contentType);
|
||||||
|
|
||||||
for (String name : this.headers.keySet()) {
|
this.headers.forEach((name, values) -> {
|
||||||
for (Object value : this.headers.get(name)) {
|
for (Object value : values) {
|
||||||
request.addHeader(name, value);
|
request.addHeader(name, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (this.url.getRawQuery() != null) {
|
if (this.url.getRawQuery() != null) {
|
||||||
request.setQueryString(this.url.getRawQuery());
|
request.setQueryString(this.url.getRawQuery());
|
||||||
}
|
}
|
||||||
addRequestParams(request, UriComponentsBuilder.fromUri(this.url).build().getQueryParams());
|
addRequestParams(request, UriComponentsBuilder.fromUri(this.url).build().getQueryParams());
|
||||||
|
|
||||||
for (String name : this.parameters.keySet()) {
|
this.parameters.forEach((name, values) -> {
|
||||||
for (String value : this.parameters.get(name)) {
|
for (String value : values) {
|
||||||
request.addParameter(name, value);
|
request.addParameter(name, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (this.content != null && this.content.length > 0) {
|
if (this.content != null && this.content.length > 0) {
|
||||||
String requestContentType = request.getContentType();
|
String requestContentType = request.getContentType();
|
||||||
|
|
@ -658,14 +654,12 @@ public class MockHttpServletRequestBuilder
|
||||||
request.setPreferredLocales(this.locales);
|
request.setPreferredLocales(this.locales);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String name : this.requestAttributes.keySet()) {
|
this.requestAttributes.forEach(request::setAttribute);
|
||||||
request.setAttribute(name, this.requestAttributes.get(name));
|
this.sessionAttributes.forEach((name, attribute) -> {
|
||||||
}
|
|
||||||
for (String name : this.sessionAttributes.keySet()) {
|
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
Assert.state(session != null, "No HttpSession");
|
Assert.state(session != null, "No HttpSession");
|
||||||
session.setAttribute(name, this.sessionAttributes.get(name));
|
session.setAttribute(name, attribute);
|
||||||
}
|
});
|
||||||
|
|
||||||
FlashMap flashMap = new FlashMap();
|
FlashMap flashMap = new FlashMap();
|
||||||
flashMap.putAll(this.flashAttributes);
|
flashMap.putAll(this.flashAttributes);
|
||||||
|
|
|
||||||
|
|
@ -135,13 +135,13 @@ public class PrintingResultHandler implements ResultHandler {
|
||||||
protected final MultiValueMap<String, String> getParamsMultiValueMap(MockHttpServletRequest request) {
|
protected final MultiValueMap<String, String> getParamsMultiValueMap(MockHttpServletRequest request) {
|
||||||
Map<String, String[]> params = request.getParameterMap();
|
Map<String, String[]> params = request.getParameterMap();
|
||||||
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
|
||||||
for (String name : params.keySet()) {
|
params.forEach((name, values) -> {
|
||||||
if (params.get(name) != null) {
|
if (params.get(name) != null) {
|
||||||
for (String value : params.get(name)) {
|
for (String value : values) {
|
||||||
multiValueMap.add(name, value);
|
multiValueMap.add(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return multiValueMap;
|
return multiValueMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,10 +235,10 @@ public class PrintingResultHandler implements ResultHandler {
|
||||||
this.printer.printValue("Attributes", null);
|
this.printer.printValue("Attributes", null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (String name : flashMap.keySet()) {
|
flashMap.forEach((name, value) -> {
|
||||||
this.printer.printValue("Attribute", name);
|
this.printer.printValue("Attribute", name);
|
||||||
this.printer.printValue("value", flashMap.get(name));
|
this.printer.printValue("value", value);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -660,9 +660,7 @@ public class Jackson2ObjectMapperBuilder {
|
||||||
objectMapper.setFilterProvider(this.filters);
|
objectMapper.setFilterProvider(this.filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Class<?> target : this.mixIns.keySet()) {
|
this.mixIns.forEach((target, mixinSource) -> objectMapper.addMixIn(target, mixinSource));
|
||||||
objectMapper.addMixIn(target, this.mixIns.get(target));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.serializers.isEmpty() || !this.deserializers.isEmpty()) {
|
if (!this.serializers.isEmpty() || !this.deserializers.isEmpty()) {
|
||||||
SimpleModule module = new SimpleModule();
|
SimpleModule module = new SimpleModule();
|
||||||
|
|
@ -672,9 +670,7 @@ public class Jackson2ObjectMapperBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
customizeDefaultFeatures(objectMapper);
|
customizeDefaultFeatures(objectMapper);
|
||||||
for (Object feature : this.features.keySet()) {
|
this.features.forEach((feature, enabled) -> configureFeature(objectMapper, feature, enabled));
|
||||||
configureFeature(objectMapper, feature, this.features.get(feature));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.handlerInstantiator != null) {
|
if (this.handlerInstantiator != null) {
|
||||||
objectMapper.setHandlerInstantiator(this.handlerInstantiator);
|
objectMapper.setHandlerInstantiator(this.handlerInstantiator);
|
||||||
|
|
@ -699,16 +695,14 @@ public class Jackson2ObjectMapperBuilder {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> void addSerializers(SimpleModule module) {
|
private <T> void addSerializers(SimpleModule module) {
|
||||||
for (Class<?> type : this.serializers.keySet()) {
|
this.serializers.forEach((type, serializer) ->
|
||||||
module.addSerializer((Class<? extends T>) type, (JsonSerializer<T>) this.serializers.get(type));
|
module.addSerializer((Class<? extends T>) type, (JsonSerializer<T>) serializer));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> void addDeserializers(SimpleModule module) {
|
private <T> void addDeserializers(SimpleModule module) {
|
||||||
for (Class<?> type : this.deserializers.keySet()) {
|
this.deserializers.forEach((type, deserializer) ->
|
||||||
module.addDeserializer((Class<T>) type, (JsonDeserializer<? extends T>) this.deserializers.get(type));
|
module.addDeserializer((Class<T>) type, (JsonDeserializer<? extends T>) deserializer));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
|
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
|
||||||
|
|
|
||||||
|
|
@ -112,12 +112,11 @@ public class SessionAttributesHandler {
|
||||||
* @param attributes candidate attributes for session storage
|
* @param attributes candidate attributes for session storage
|
||||||
*/
|
*/
|
||||||
public void storeAttributes(WebRequest request, Map<String, ?> attributes) {
|
public void storeAttributes(WebRequest request, Map<String, ?> attributes) {
|
||||||
for (String name : attributes.keySet()) {
|
attributes.forEach((name, value) -> {
|
||||||
Object value = attributes.get(name);
|
|
||||||
if (value != null && isHandlerSessionAttribute(name, value.getClass())) {
|
if (value != null && isHandlerSessionAttribute(name, value.getClass())) {
|
||||||
this.sessionAttributeStore.storeAttribute(request, name, value);
|
this.sessionAttributeStore.storeAttribute(request, name, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -567,11 +567,11 @@ public class UrlPathHelper {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap<>(vars.size());
|
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap<>(vars.size());
|
||||||
for (String key : vars.keySet()) {
|
vars.forEach((key, values) -> {
|
||||||
for (String value : vars.get(key)) {
|
for (String value : values) {
|
||||||
decodedVars.add(key, decodeInternal(request, value));
|
decodedVars.add(key, decodeInternal(request, value));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return decodedVars;
|
return decodedVars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,11 +90,11 @@ public class MatrixVariableMapMethodArgumentResolver extends HandlerMethodArgume
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (MultiValueMap<String, String> vars : matrixVariables.values()) {
|
for (MultiValueMap<String, String> vars : matrixVariables.values()) {
|
||||||
for (String name : vars.keySet()) {
|
vars.forEach((name, values) -> {
|
||||||
for (String value : vars.get(name)) {
|
for (String value : values) {
|
||||||
map.add(name, value);
|
map.add(name, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,11 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
|
||||||
*/
|
*/
|
||||||
public FlashMap addTargetRequestParams(@Nullable MultiValueMap<String, String> params) {
|
public FlashMap addTargetRequestParams(@Nullable MultiValueMap<String, String> params) {
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
for (String key : params.keySet()) {
|
params.forEach((key, values) -> {
|
||||||
for (String value : params.get(key)) {
|
for (String value : values) {
|
||||||
addTargetRequestParam(key, value);
|
addTargetRequestParam(key, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,11 +86,11 @@ public class MatrixVariableMapMethodArgumentResolver implements HandlerMethodArg
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (MultiValueMap<String, String> vars : matrixVariables.values()) {
|
for (MultiValueMap<String, String> vars : matrixVariables.values()) {
|
||||||
for (String name : vars.keySet()) {
|
vars.forEach((name, values) -> {
|
||||||
for (String value : vars.get(name)) {
|
for (String value : values) {
|
||||||
map.add(name, value);
|
map.add(name, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,7 @@ public class RedirectAttributesModelMap extends ModelMap implements RedirectAttr
|
||||||
@Override
|
@Override
|
||||||
public RedirectAttributesModelMap addAllAttributes(@Nullable Map<String, ?> attributes) {
|
public RedirectAttributesModelMap addAllAttributes(@Nullable Map<String, ?> attributes) {
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
for (String key : attributes.keySet()) {
|
attributes.forEach(this::addAttribute);
|
||||||
addAttribute(key, attributes.get(key));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -125,11 +123,11 @@ public class RedirectAttributesModelMap extends ModelMap implements RedirectAttr
|
||||||
@Override
|
@Override
|
||||||
public RedirectAttributesModelMap mergeAttributes(@Nullable Map<String, ?> attributes) {
|
public RedirectAttributesModelMap mergeAttributes(@Nullable Map<String, ?> attributes) {
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
for (String key : attributes.keySet()) {
|
attributes.forEach((key, attribute) -> {
|
||||||
if (!containsKey(key)) {
|
if (!containsKey(key)) {
|
||||||
addAttribute(key, attributes.get(key));
|
addAttribute(key, attribute);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -155,9 +153,7 @@ public class RedirectAttributesModelMap extends ModelMap implements RedirectAttr
|
||||||
@Override
|
@Override
|
||||||
public void putAll(@Nullable Map<? extends String, ? extends Object> map) {
|
public void putAll(@Nullable Map<? extends String, ? extends Object> map) {
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
for (String key : map.keySet()) {
|
map.forEach((key, value) -> put(key, formatValue(value)));
|
||||||
put(key, formatValue(map.get(key)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,11 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||||
|
|
||||||
HttpHeaders headersToUse = new HttpHeaders();
|
HttpHeaders headersToUse = new HttpHeaders();
|
||||||
if (headers != null) {
|
if (headers != null) {
|
||||||
for (String header : headers.keySet()) {
|
headers.forEach((header, values) -> {
|
||||||
List<String> values = headers.get(header);
|
|
||||||
if (values != null && !specialHeaders.contains(header.toLowerCase())) {
|
if (values != null && !specialHeaders.contains(header.toLowerCase())) {
|
||||||
headersToUse.put(header, values);
|
headersToUse.put(header, values);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> subProtocols =
|
List<String> subProtocols =
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,7 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
|
||||||
request.addExtensions(new WebSocketToJettyExtensionConfigAdapter(e));
|
request.addExtensions(new WebSocketToJettyExtensionConfigAdapter(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String header : headers.keySet()) {
|
headers.forEach(request::setHeader);
|
||||||
request.setHeader(header, headers.get(header));
|
|
||||||
}
|
|
||||||
|
|
||||||
Principal user = getUser();
|
Principal user = getUser();
|
||||||
final JettyWebSocketSession wsSession = new JettyWebSocketSession(attributes, user);
|
final JettyWebSocketSession wsSession = new JettyWebSocketSession(attributes, user);
|
||||||
|
|
|
||||||
|
|
@ -153,21 +153,21 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
|
||||||
M mappings = createMappings();
|
M mappings = createMappings();
|
||||||
if (this.sockJsServiceRegistration != null) {
|
if (this.sockJsServiceRegistration != null) {
|
||||||
SockJsService sockJsService = this.sockJsServiceRegistration.getSockJsService();
|
SockJsService sockJsService = this.sockJsServiceRegistration.getSockJsService();
|
||||||
for (WebSocketHandler wsHandler : this.handlerMap.keySet()) {
|
this.handlerMap.forEach((wsHandler, paths) -> {
|
||||||
for (String path : this.handlerMap.get(wsHandler)) {
|
for (String path : paths) {
|
||||||
String pathPattern = (path.endsWith("/") ? path + "**" : path + "/**");
|
String pathPattern = (path.endsWith("/") ? path + "**" : path + "/**");
|
||||||
addSockJsServiceMapping(mappings, sockJsService, wsHandler, pathPattern);
|
addSockJsServiceMapping(mappings, sockJsService, wsHandler, pathPattern);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
HandshakeHandler handshakeHandler = getOrCreateHandshakeHandler();
|
HandshakeHandler handshakeHandler = getOrCreateHandshakeHandler();
|
||||||
HandshakeInterceptor[] interceptors = getInterceptors();
|
HandshakeInterceptor[] interceptors = getInterceptors();
|
||||||
for (WebSocketHandler wsHandler : this.handlerMap.keySet()) {
|
this.handlerMap.forEach((wsHandler, paths) -> {
|
||||||
for (String path : this.handlerMap.get(wsHandler)) {
|
for (String path : paths) {
|
||||||
addWebSocketHandlerMapping(mappings, wsHandler, handshakeHandler, interceptors, path);
|
addWebSocketHandlerMapping(mappings, wsHandler, handshakeHandler, interceptors, path);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mappings;
|
return mappings;
|
||||||
|
|
|
||||||
|
|
@ -127,11 +127,11 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
|
||||||
for (ServletWebSocketHandlerRegistration registration : this.registrations) {
|
for (ServletWebSocketHandlerRegistration registration : this.registrations) {
|
||||||
updateTaskScheduler(registration);
|
updateTaskScheduler(registration);
|
||||||
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
|
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
|
||||||
for (HttpRequestHandler httpHandler : mappings.keySet()) {
|
mappings.forEach((httpHandler, patterns) -> {
|
||||||
for (String pattern : mappings.get(httpHandler)) {
|
for (String pattern : patterns) {
|
||||||
urlMap.put(pattern, httpHandler);
|
urlMap.put(pattern, httpHandler);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
|
WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
|
||||||
hm.setUrlMap(urlMap);
|
hm.setUrlMap(urlMap);
|
||||||
|
|
|
||||||
|
|
@ -150,11 +150,11 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
||||||
Map<String, Object> urlMap = new LinkedHashMap<>();
|
Map<String, Object> urlMap = new LinkedHashMap<>();
|
||||||
for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
|
for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
|
||||||
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
|
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
|
||||||
for (HttpRequestHandler httpHandler : mappings.keySet()) {
|
mappings.forEach((httpHandler, patterns) -> {
|
||||||
for (String pattern : mappings.get(httpHandler)) {
|
for (String pattern : patterns) {
|
||||||
urlMap.put(pattern, httpHandler);
|
urlMap.put(pattern, httpHandler);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
|
WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
|
||||||
hm.setUrlMap(urlMap);
|
hm.setUrlMap(urlMap);
|
||||||
|
|
|
||||||
|
|
@ -184,9 +184,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
||||||
.secure(request.isSecure())
|
.secure(request.isSecure())
|
||||||
.remoteAddr(request.getRemoteAddr())
|
.remoteAddr(request.getRemoteAddr())
|
||||||
.build();
|
.build();
|
||||||
for (String header : headers.keySet()) {
|
headers.forEach((header, value) -> context.getHeaders().put(header, value));
|
||||||
context.getHeaders().put(header, headers.get(header));
|
|
||||||
}
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue