Affects: SpringBoot 3.0.3/Spring Framework 6.0.5
I have multiple WebClient instances that uses a target's name without a scheme. Ex:
var client = WebClient.builder().baseUrl("service1").build();
client.get().retrieve().bodyToMono(String.class)...
With SpringBoot 3.0.2 and below (including all current version of SpringBoot 2.x including 2.7.9), the above code will
resolve service1
to a DNS name and execute the GET
request and expected.
As I upgrade to SpringBoot 3.0.3, the above code will now throw an exception with the following error:
Caused by: java.lang.IllegalArgumentException: URI is not absolute: service1
It appears the framework is expecting the target name to now include a scheme prefix such as http://
or https://
.
Is this behavior an intended change or a bug?
Comment From: rstoyanchev
This is due to dd3dc2d0 from #29954. It looks like Reactor Netty's HttpClient is less strict when the URI is provided as a String, and fills in some defaults in UriEndpointFactory
.
We can check if the URI is absolute, and if not, fall back on uri.toString()
as it was before 6.0.5.