Affects: 5.3.28 and maybe older versions as well
Steps to reproduce:
- Create
WebClientinstance withbaseURLwhich contains the port (WebClient.builder().baseUrl("localhost:8081")...for example). - Try to make a call to any endpoint on that base URL (
webClient.uri("/test-endpoint")...orwebClient.uri("test-endpoint")...for example).
Actual behavior:
Request is made to localhost/test-endpoint.
Expected behavior:
Request is made to localhost:8081/test-endpoint.
Such behavior is caused by this check in org.springframework.web.util.HierarchicalUriComponents#copyToUriComponentsBuilder.
Documentation says nothing about this behavior, and it is quite illogical to me.
Is there a way to bypass this problem with current Spring version?
Comment From: watari
But it works as expected when base URL contains information about protocol (http:///https://)
Comment From: sbrannen
I believe the underlying cause is the parsing performed in UriComponentsBuilder.fromUriString(String).
Comment From: bclozel
duplicates #31033