Affects: 6.1.1

The following code snippet works with Spring 5.3.x but fails with Spring 6.1.1:

WebClient.create("http://my_url:4000").get().retrieve().toBodilessEntity().block();

Reactory Netty is used as an HTTP Client.

With Spring 6.1.1, the following exception occurs:

org.springframework.web.reactive.function.client.WebClientRequestException: Host is not specified

    at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:136)
    Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below: 
Error has been observed at the following site(s):
    *__checkpoint ⇢ Request to GET null [DefaultWebClient]
Original Stack Trace:
        at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:136)
        at reactor.core.publisher.MonoErrorSupplied.subscribe(MonoErrorSupplied.java:55)
        at reactor.core.publisher.Mono.subscribe(Mono.java:4512)
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
        at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:222)
        at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:222)
        at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:222)
        at reactor.core.publisher.MonoNext$NextSubscriber.onError(MonoNext.java:93)
        at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onError(MonoFlatMapMany.java:204)
        at reactor.core.publisher.Operators.reportThrowInSubscribe(Operators.java:232)
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:83)
        at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55)
        at reactor.core.publisher.Mono.subscribe(Mono.java:4512)
        at reactor.core.publisher.Mono.block(Mono.java:1727)
        at com.example.springjpalock.WebClientTest.test(WebClientTest.java:11)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    Suppressed: java.lang.Exception: #block terminated with an error
        at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:103)
        at reactor.core.publisher.Mono.block(Mono.java:1728)
        at com.example.springjpalock.WebClientTest.test(WebClientTest.java:11)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.IllegalArgumentException: Host is not specified
    at reactor.netty.http.client.UriEndpointFactory.createUriEndpoint(UriEndpointFactory.java:79)
    at reactor.netty.http.client.HttpClientConnect$HttpClientHandler.<init>(HttpClientConnect.java:512)
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:208)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)
    at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4512)
    at reactor.core.publisher.Mono.block(Mono.java:1727)
    at com.example.springjpalock.WebClientTest.test(WebClientTest.java:11)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

Comment From: quaff

A domain name cannot have an underscore for these reasons: The RFC 1035 code and ICANN prohibit the user underscores in a domain name. It only allows the use of alphanumeric characters such as letters A to Z, and numbers 0 to 9.

my_url is not valid host.

Comment From: snicoll

@hannosgit is it literally my_host? If not, can you share a small sample usage of the web client that reproduces the issue? You can attach that as a zip or push the code to a separate GitHub repo.

Comment From: hannosgit

@snicoll We use WebClient to make requests to our microservices through the Docker network. Unfortunately, we use underscores in our container names and therefore their hostnames contain underscores. E.g. to make a request to our Authentication service, we use

WebClient.create("http://auth_service:4000/user/123").get().retrieve().toBodilessEntity().block();

The given code snippet plus e.g the spring-boot-starter-webflux dependency, should be enough to reproduce this issue.

Comment From: poutsma

The stacktrace indicates that the exception is thrown from Reactor Netty, so please file an issue with Reactor Netty if you think this is an issue that should be resolved.

FWIW, this is most likely due to the fact, as indicated by @quaff, that RFC 1035 and therefore Java does not support host names with underscores in them. I would recommend changing your hosts names, or expect to run into more problems in the future.