UriComponentsBuilder
is encoding your URI in accordance with RFC 3986, with section 3.4 about the ‘query’ component of a URI being of particular note.
Within the ‘query’ component, the characters “https://stackoverflow.com/” and ‘:’ are permitted, and do not need escaping.
To take the “https://stackoverflow.com/” character for example: the ‘query’ component (which is clearly delimited by unescaped ‘?’ and (optionally) ‘#’ characters), is not hierarchical and the “https://stackoverflow.com/” character has no special meaning. So it doesn’t need encoding.