HttpEntity.EMPTY should be immutable

See gh-34812

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
Yanming Zhou
2025-04-24 17:36:29 +08:00
committed by rstoyanchev
parent 5013d6d771
commit d7c13d6518
2 changed files with 10 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Arjen Poutsma
* @author Yanming Zhou
*/
class HttpEntityTests {
@@ -123,4 +124,11 @@ class HttpEntityTests {
assertThat(requestEntity2).isEqualTo(requestEntity);
}
@Test
void emptyHttpEntityShouldBeImmutable() {
HttpHeaders newHeaders = new HttpHeaders(HttpEntity.EMPTY.getHeaders());
newHeaders.add("Authorization", "Bearer some-token");
assertThat(HttpEntity.EMPTY.getHeaders().headerNames()).isEmpty();
}
}