Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebClient now requires scheme #30053

Closed
gm2552 opened this issue Feb 28, 2023 · 1 comment
Closed

WebClient now requires scheme #30053

gm2552 opened this issue Feb 28, 2023 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@gm2552
Copy link

gm2552 commented Feb 28, 2023

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?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 28, 2023
@rstoyanchev rstoyanchev self-assigned this Mar 1, 2023
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 1, 2023
@rstoyanchev rstoyanchev added this to the 6.0.6 milestone Mar 1, 2023
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Mar 1, 2023

This is due to dd3dc2d 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.

@rstoyanchev rstoyanchev changed the title WebClient now requiring scheme prefix WebClient now requires scheme Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants