Skip to content

Commit d8503da

Browse files
committed
Revise how bodyType is set for 7.0 codebase
See gh-34793
1 parent fed6e9b commit d8503da

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestValues.java

+13-16
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,19 @@ public class HttpRequestValues {
7575

7676
private final @Nullable Object bodyValue;
7777

78-
private @Nullable ParameterizedTypeReference<?> bodyValueType;
78+
private final @Nullable ParameterizedTypeReference<?> bodyValueType;
7979

8080

8181
/**
8282
* Construct {@link HttpRequestValues}.
83-
* @since 6.1
83+
* @since 7.0
8484
*/
8585
protected HttpRequestValues(@Nullable HttpMethod httpMethod,
8686
@Nullable URI uri, @Nullable UriBuilderFactory uriBuilderFactory,
8787
@Nullable String uriTemplate, Map<String, String> uriVariables,
88-
HttpHeaders headers, MultiValueMap<String, String> cookies, @Nullable Object version,
89-
Map<String, Object> attributes, @Nullable Object bodyValue) {
88+
HttpHeaders headers, MultiValueMap<String, String> cookies,
89+
@Nullable Object version, Map<String, Object> attributes,
90+
@Nullable Object bodyValue, @Nullable ParameterizedTypeReference<?> bodyValueType) {
9091

9192
Assert.isTrue(uri != null || uriTemplate != null, "Neither URI nor URI template");
9293

@@ -100,6 +101,7 @@ protected HttpRequestValues(@Nullable HttpMethod httpMethod,
100101
this.version = version;
101102
this.attributes = attributes;
102103
this.bodyValue = bodyValue;
104+
this.bodyValueType = bodyValueType;
103105
}
104106

105107

@@ -511,14 +513,9 @@ else if (uri != null) {
511513
Map<String, Object> attributes = (this.attributes != null ?
512514
new HashMap<>(this.attributes) : Collections.emptyMap());
513515

514-
HttpRequestValues requestValues = createRequestValues(
516+
return createRequestValues(
515517
this.httpMethod, uri, uriBuilderFactory, uriTemplate, uriVars,
516-
headers, cookies, this.version, attributes, bodyValue);
517-
518-
// In 6.2.x only, temporarily work around protected methods
519-
requestValues.bodyValueType = this.bodyValueType;
520-
521-
return requestValues;
518+
headers, cookies, this.version, attributes, bodyValue, this.bodyValueType);
522519
}
523520

524521
protected boolean hasParts() {
@@ -557,18 +554,18 @@ private String appendQueryParams(
557554

558555
/**
559556
* Create {@link HttpRequestValues} from values passed to the {@link Builder}.
560-
* @since 6.1
557+
* @since 7.0
561558
*/
562559
protected HttpRequestValues createRequestValues(
563560
@Nullable HttpMethod httpMethod,
564561
@Nullable URI uri, @Nullable UriBuilderFactory uriBuilderFactory, @Nullable String uriTemplate,
565-
Map<String, String> uriVars,
566-
HttpHeaders headers, MultiValueMap<String, String> cookies, @Nullable Object version,
567-
Map<String, Object> attributes, @Nullable Object bodyValue) {
562+
Map<String, String> uriVars, HttpHeaders headers, MultiValueMap<String, String> cookies,
563+
@Nullable Object version, Map<String, Object> attributes,
564+
@Nullable Object bodyValue, @Nullable ParameterizedTypeReference<?> bodyValueType) {
568565

569566
return new HttpRequestValues(
570567
this.httpMethod, uri, uriBuilderFactory, uriTemplate,
571-
uriVars, headers, cookies, version, attributes, bodyValue);
568+
uriVars, headers, cookies, version, attributes, bodyValue, bodyValueType);
572569
}
573570
}
574571

spring-web/src/main/java/org/springframework/web/service/invoker/ReactiveHttpRequestValues.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ private ReactiveHttpRequestValues(
5050
@Nullable HttpMethod httpMethod,
5151
@Nullable URI uri, @Nullable UriBuilderFactory uriBuilderFactory,
5252
@Nullable String uriTemplate, Map<String, String> uriVars,
53-
HttpHeaders headers, MultiValueMap<String, String> cookies, @Nullable Object version,
54-
Map<String, Object> attributes,
55-
@Nullable Object bodyValue, @Nullable Publisher<?> body,
56-
@Nullable ParameterizedTypeReference<?> elementType) {
53+
HttpHeaders headers, MultiValueMap<String, String> cookies,
54+
@Nullable Object version, Map<String, Object> attributes,
55+
@Nullable Object bodyValue, @Nullable ParameterizedTypeReference<?> bodyValueType,
56+
@Nullable Publisher<?> body, @Nullable ParameterizedTypeReference<?> elementType) {
57+
58+
super(httpMethod,
59+
uri, uriBuilderFactory, uriTemplate, uriVars,
60+
headers, cookies, version, attributes,
61+
bodyValue, bodyValueType);
5762

58-
super(httpMethod, uri, uriBuilderFactory, uriTemplate, uriVars, headers, cookies, version, attributes, bodyValue);
5963
this.body = body;
6064
this.bodyElementType = elementType;
6165
}
@@ -237,12 +241,13 @@ protected ReactiveHttpRequestValues createRequestValues(
237241
@Nullable HttpMethod httpMethod,
238242
@Nullable URI uri, @Nullable UriBuilderFactory uriBuilderFactory,
239243
@Nullable String uriTemplate, Map<String, String> uriVars,
240-
HttpHeaders headers, MultiValueMap<String, String> cookies, @Nullable Object version,
241-
Map<String, Object> attributes, @Nullable Object bodyValue) {
244+
HttpHeaders headers, MultiValueMap<String, String> cookies,
245+
@Nullable Object version, Map<String, Object> attributes,
246+
@Nullable Object bodyValue, @Nullable ParameterizedTypeReference<?> bodyValueType) {
242247

243248
return new ReactiveHttpRequestValues(
244249
httpMethod, uri, uriBuilderFactory, uriTemplate, uriVars,
245-
headers, cookies, version, attributes, bodyValue, this.body, this.bodyElementType);
250+
headers, cookies, version, attributes, bodyValue, bodyValueType, this.body, this.bodyElementType);
246251
}
247252
}
248253

0 commit comments

Comments
 (0)