File tree 2 files changed +10
-4
lines changed
main/java/org/springframework/http
test/java/org/springframework/http
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 92
92
* @author Josh Long
93
93
* @author Sam Brannen
94
94
* @author Simon Baslé
95
+ * @author Yanming Zhou
95
96
* @since 3.0
96
97
*/
97
98
public class HttpHeaders implements Serializable {
@@ -473,10 +474,7 @@ public HttpHeaders(HttpHeaders httpHeaders) {
473
474
this .headers = CollectionUtils .toMultiValueMap (new LinkedCaseInsensitiveMap <>(8 , Locale .ENGLISH ));
474
475
}
475
476
else {
476
- while (httpHeaders .headers instanceof HttpHeaders wrapped ) {
477
- httpHeaders = wrapped ;
478
- }
479
- this .headers = httpHeaders .headers ;
477
+ this .headers = new LinkedMultiValueMap <>(httpHeaders .headers );
480
478
}
481
479
}
482
480
Original file line number Diff line number Diff line change 24
24
25
25
/**
26
26
* @author Arjen Poutsma
27
+ * @author Yanming Zhou
27
28
*/
28
29
class HttpEntityTests {
29
30
@@ -120,4 +121,11 @@ void requestEntity() {
120
121
assertThat (requestEntity2 ).isEqualTo (requestEntity );
121
122
}
122
123
124
+ @ Test
125
+ void emptyHttpEntityShouldBeImmutable () {
126
+ HttpHeaders newHeaders = new HttpHeaders (HttpEntity .EMPTY .getHeaders ());
127
+ newHeaders .add ("Authorization" , "Bearer some-token" );
128
+ assertThat (HttpEntity .EMPTY .getHeaders ().headerNames ()).isEmpty ();
129
+ }
130
+
123
131
}
You can’t perform that action at this time.
0 commit comments