File tree 2 files changed +10
-1
lines changed
main/java/org/springframework/http
test/java/org/springframework/http
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 49
49
*
50
50
* @author Arjen Poutsma
51
51
* @author Juergen Hoeller
52
+ * @author Yanming Zhou
52
53
* @since 3.0.2
53
54
* @param <T> the body type
54
55
* @see org.springframework.web.client.RestTemplate
@@ -60,7 +61,7 @@ public class HttpEntity<T> {
60
61
/**
61
62
* The empty {@code HttpEntity}, with no body or headers.
62
63
*/
63
- public static final HttpEntity <?> EMPTY = new HttpEntity <>();
64
+ public static final HttpEntity <?> EMPTY = new HttpEntity <>(HttpHeaders . EMPTY );
64
65
65
66
66
67
private final HttpHeaders headers ;
Original file line number Diff line number Diff line change 27
27
28
28
/**
29
29
* @author Arjen Poutsma
30
+ * @author Yanming Zhou
30
31
*/
31
32
class HttpEntityTests {
32
33
@@ -123,4 +124,11 @@ void requestEntity() {
123
124
assertThat (requestEntity2 ).isEqualTo (requestEntity );
124
125
}
125
126
127
+ @ Test
128
+ void emptyHttpEntityShouldBeImmutable () {
129
+ HttpHeaders newHeaders = new HttpHeaders (HttpEntity .EMPTY .getHeaders ());
130
+ newHeaders .add ("Authorization" , "Bearer some-token" );
131
+ assertThat (HttpEntity .EMPTY .getHeaders ().headerNames ()).isEmpty ();
132
+ }
133
+
126
134
}
You can’t perform that action at this time.
0 commit comments