Skip to content

Incompatibility with Spring WebFlux 5.1 WebClient #938

@scottfrederick

Description

@scottfrederick

When CF Java Client is used in an application that also uses WebClient from Spring WebFlux 2.1.x.RELEASE, exceptions are thrown from Netty and connections to CF fail.

The relevant exception is:

Caused by: java.lang.IllegalArgumentException: 'httpRedirects' is already in use
	at io.netty.util.ConstantPool.createOrThrow(ConstantPool.java:113) ~[netty-common-4.1.31.Final.jar:4.1.31.Final]
	at io.netty.util.ConstantPool.newInstance(ConstantPool.java:95) ~[netty-common-4.1.31.Final.jar:4.1.31.Final]
	at io.netty.util.AttributeKey.newInstance(AttributeKey.java:55) ~[netty-common-4.1.31.Final.jar:4.1.31.Final]
	at reactor.netty.http.client.HttpClientOperations.<clinit>(HttpClientOperations.java:720) ~[reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]

The root of the issue is clashing versions of reactor-netty.

  • CFJC 3.x depends on io.projectreactor.ipc:reactor-netty:0.7.x.RELEASE (via spring-boot-dependencies:2.0.x).
  • Spring WebFlux 2.1.x depends on io.projectreactor.netty.reactor-netty:0.8.x.RELEASE.

These versions of reactor-netty both have a class with a static initializer that registers a "constant" with Netty:

Whichever of these initializers runs first wins, and the second one fails. When the HttpClientOperations used by CFJC fails to initialize, the exception above appears in stdout but the app will start. Subsequent calls to CFJC result in long delays followed by a timeout.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions