Skip to content

Commit a575590

Browse files
committed
Merge branch '5.3.x'
2 parents 8c063a0 + 058ce36 commit a575590

File tree

6 files changed

+18
-30
lines changed

6 files changed

+18
-30
lines changed

spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public Mono<Void> bind(ServerWebExchange exchange) {
8484
}
8585

8686
/**
87-
* Protected method to obtain the values for data binding. By default this
88-
* method delegates to {@link #extractValuesToBind(ServerWebExchange)}.
87+
* Obtain the values for data binding. By default, this delegates to
88+
* {@link #extractValuesToBind(ServerWebExchange)}.
8989
* @param exchange the current exchange
9090
* @return a map of bind values
9191
* @since 5.3

spring-webflux/src/main/java/org/springframework/web/reactive/BindingContext.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,14 +18,11 @@
1818

1919
import java.util.Collections;
2020
import java.util.Map;
21-
import java.util.TreeMap;
2221

2322
import reactor.core.publisher.Mono;
2423

25-
import org.springframework.http.codec.multipart.Part;
2624
import org.springframework.lang.Nullable;
2725
import org.springframework.ui.Model;
28-
import org.springframework.util.MultiValueMap;
2926
import org.springframework.validation.support.BindingAwareConcurrentModel;
3027
import org.springframework.web.bind.support.WebBindingInitializer;
3128
import org.springframework.web.bind.support.WebExchangeDataBinder;
@@ -127,21 +124,9 @@ public ExtendedWebExchangeDataBinder(@Nullable Object target, String objectName)
127124

128125
@Override
129126
public Mono<Map<String, Object>> getValuesToBind(ServerWebExchange exchange) {
130-
Map<String, String> vars = exchange.getAttributeOrDefault(
131-
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, Collections.emptyMap());
132-
MultiValueMap<String, String> queryParams = exchange.getRequest().getQueryParams();
133-
Mono<MultiValueMap<String, String>> formData = exchange.getFormData();
134-
Mono<MultiValueMap<String, Part>> multipartData = exchange.getMultipartData();
135-
136-
return Mono.zip(Mono.just(vars), Mono.just(queryParams), formData, multipartData)
137-
.map(tuple -> {
138-
Map<String, Object> result = new TreeMap<>();
139-
tuple.getT1().forEach(result::put);
140-
tuple.getT2().forEach((key, values) -> addBindValue(result, key, values));
141-
tuple.getT3().forEach((key, values) -> addBindValue(result, key, values));
142-
tuple.getT4().forEach((key, values) -> addBindValue(result, key, values));
143-
return result;
144-
});
127+
return super.getValuesToBind(exchange).doOnNext(map ->
128+
map.putAll(exchange.<Map<String, String>>getAttributeOrDefault(
129+
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, Collections.emptyMap())));
145130
}
146131
}
147132

spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/JettyWebSocketClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -164,7 +164,7 @@ private Object createHandler(URI url, WebSocketHandler handler, Sinks.Empty<Void
164164

165165
private HandshakeInfo createHandshakeInfo(URI url, Session jettySession) {
166166
HttpHeaders headers = new HttpHeaders();
167-
jettySession.getUpgradeResponse().getHeaders().forEach(headers::put);
167+
headers.putAll(jettySession.getUpgradeResponse().getHeaders());
168168
String protocol = headers.getFirst("Sec-WebSocket-Protocol");
169169
return new HandshakeInfo(url, headers, Mono.empty(), protocol);
170170
}

spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/StandardWebSocketClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -170,7 +170,7 @@ public void beforeRequest(Map<String, List<String>> requestHeaders) {
170170

171171
@Override
172172
public void afterResponse(HandshakeResponse response) {
173-
response.getHeaders().forEach(this.responseHeaders::put);
173+
this.responseHeaders.putAll(response.getHeaders());
174174
}
175175
}
176176

spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/UndertowWebSocketClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -243,15 +243,15 @@ public HttpHeaders getResponseHeaders() {
243243

244244
@Override
245245
public void beforeRequest(Map<String, List<String>> headers) {
246-
this.requestHeaders.forEach(headers::put);
246+
headers.putAll(this.requestHeaders);
247247
if (this.delegate != null) {
248248
this.delegate.beforeRequest(headers);
249249
}
250250
}
251251

252252
@Override
253253
public void afterRequest(Map<String, List<String>> headers) {
254-
headers.forEach(this.responseHeaders::put);
254+
this.responseHeaders.putAll(headers);
255255
if (this.delegate != null) {
256256
this.delegate.afterRequest(headers);
257257
}

spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,8 @@ protected void doService(HttpServletRequest request, HttpServletResponse respons
975975
private void logRequest(HttpServletRequest request) {
976976
LogFormatUtils.traceDebug(logger, traceOn -> {
977977
String params;
978-
if (StringUtils.startsWithIgnoreCase(request.getContentType(), "multipart/")) {
978+
String contentType = request.getContentType();
979+
if (StringUtils.startsWithIgnoreCase(contentType, "multipart/")) {
979980
params = "multipart";
980981
}
981982
else if (isEnableLoggingRequestDetails()) {
@@ -984,7 +985,9 @@ else if (isEnableLoggingRequestDetails()) {
984985
.collect(Collectors.joining(", "));
985986
}
986987
else {
987-
params = (request.getParameterMap().isEmpty() ? "" : "masked");
988+
// Avoid request body parsing for form data
989+
params = (StringUtils.startsWithIgnoreCase(contentType, "application/x-www-form-urlencoded") ||
990+
!request.getParameterMap().isEmpty() ? "masked" : "");
988991
}
989992

990993
String queryString = request.getQueryString();

0 commit comments

Comments
 (0)