SpringBoot Version: 2.3.11.RELEASE
We use a shaded version of reactor-netty, by default, for our internal WebClient extensions and intentionally, for springboot 2.3.x do not include reactor-netty due to a variety of versions, conflicts, contention over this library across hundreds of projects.
Recently, app owners who use SpringBootTest for web environment RANDOM_PORT and who transitively brought in WebClient extensions - spring-webflux only - encounter:
java.lang.NoClassDefFoundError: reactor/netty/http/client/HttpClient
We expose the WebClient interface from spring-webflux
only. However WebTestClientContextCustomizerFactory::isWebClientPresent()
is the only check guarding the use of the reactor-netty based connector employed vis-a-vis WebTestClientContextCustomizer
, leading to the chain:
WebTestClientContextCustomizer.WebTestClientFactory::createWebTestClient()
WebTestClient.bindToServer()
new DefaultWebTestClientBuilder()
new ReactorClientHttpConnector()
The last, of course fails - there is no reactor-netty and it was never checked. The last portion of this chain passes through a static WebTestClient.bindToServer
and non public classes that cannot be overridden. I don't think its safe to assume that if one is using the WebClient API that its automatically means they are also using reactor-netty, etc, etc. I believe there should be additional checks here, at a minimum. (cc @smaldini )
Comment From: wilkinsona
Thanks for the report, @jleibund. Please note that Spring Boot 2.3.x has reached the end of its open source support period. As a result, this issue will be fixed in 2.4.x and later.
Comment From: wilkinsona
Things have changed a bit in Spring Framework 5.3 where, in addition to Reactor Netty, Jetty's HTTP client and v5 of the Apache HTTP client are also supported. As a result, an IllegalStateException
is now thrown when WebFlux is on the classpath but no supported HTTP client is available.
Comment From: jleibund
Hi @wilkinsona thx for the update. As you mention, we do not have any issues with the 2.5.x train with this internally, however this isn't released, almost all springboot apps are 2.3.x (we're jumping 2.4.x) and even when it is, it could be months or longer before hundreds of applications migrate. It will likely contain breaking changes to autoconfigurations, etc. So I was hoping that we could get a fix for 2.3.x for the long migration period.
Comment From: wilkinsona
Hi, @jleibund. Unfortunately, we can't extend the OSS support period for 2.3.x. We're a relatively small team and it's important that we strike the right balance between supporting the community and the ongoing maintenance cost. We also have existing support customers who have paid for support based on the current 12-month policy that we want to treat fairly.
You should be able to work around the problem by defining your own WebTestClient
bean. This will cause WebTestClientContextCustomizer
to back off as it only creates the WebTestClient
bean definition if the context does not already contain such a bean.
If you are interested in exploring your support options, @dussab is more than happy to discuss things with @smaldini to work something out that meets Netflix's specific needs.