Do not clear queryParams UriComponentsBuilder#query

See gh-35628

Signed-off-by: Schäfer, H.H. (Hans Hosea) <HansHosea.Schaefer@ing.de>
This commit is contained in:
Schäfer, H.H. (Hans Hosea)
2025-10-13 23:39:05 +02:00
committed by rstoyanchev
parent 1c2a24a8ed
commit 649bd3ee2d
2 changed files with 18 additions and 3 deletions
@@ -477,6 +477,24 @@ class UriComponentsBuilderTests {
assertThat(result.toUriString()).isEqualTo("https://www.ietf.org");
}
@ParameterizedTest
@EnumSource
void query(final ParserType parserType) {
final UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?foo=bar", parserType)
.query("baz=qux")
.build();
assertThat(uriComponents.getQueryParams()).isEqualTo(Map.of("foo", List.of("bar"), "baz", List.of("qux")));
}
@ParameterizedTest
@EnumSource
void queryWithNullDoesRetainQueryParameters(final ParserType parserType) {
final UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?foo=bar", parserType)
.query(null)
.build();
assertThat(uriComponents.getQueryParams()).isEqualTo(Map.of("foo", List.of("bar")));
}
@ParameterizedTest
@EnumSource
void replaceQuery(ParserType parserType) {