rsocket / rsocket-java

Java implementation of RSocket
http://rsocket.io
Apache License 2.0
2.36k stars 354 forks source link

NoSuchFieldError: rsocket-core overrides dependency for netty-buffer and therefore clashes with reactor-bom / reactor-netty #1082

Closed mdindoffer closed 1 year ago

mdindoffer commented 1 year ago

Expected Behavior

I'd love to use the latest Reactor-BOM 2022.0.3 (which includes the reactor-netty 1.1.3 and that one in turn depends on netty 4.1.89) together with latest rsocket-core and rsocket-transport-netty version 1.1.3.

Actual Behavior

This combination does not work, I get

java.lang.NoSuchFieldError: NETWORK_INTERFACES
    at io.netty.resolver.dns.DnsNameResolver.anyInterfaceSupportsIpV6(DnsNameResolver.java:170)
    at io.netty.resolver.dns.DnsNameResolver.<clinit>(DnsNameResolver.java:122)
    at io.netty.resolver.dns.DnsNameResolverBuilder.<init>(DnsNameResolverBuilder.java:52)
    at reactor.netty.transport.NameResolverProvider.newNameResolverGroup(NameResolverProvider.java:501)
    at reactor.netty.tcp.TcpResources.getOrCreateDefaultResolver(TcpResources.java:315)
    at reactor.netty.tcp.TcpClientConfig.defaultAddressResolverGroup(TcpClientConfig.java:104)
    at reactor.netty.transport.ClientTransportConfig.resolverInternal(ClientTransportConfig.java:225)
    at reactor.netty.transport.ClientTransport.connect(ClientTransport.java:59)
    at reactor.netty.tcp.TcpClient.connect(TcpClient.java:193)
    at io.rsocket.transport.netty.client.TcpClientTransport.connect(TcpClientTransport.java:118)
    at io.rsocket.core.RSocketConnector.lambda$null$6(RSocketConnector.java:551)
...

This is because while most of netty artifacts on the classpath are from 4.1.89, netty-buffer and consequently netty-common is still version 4.1.81. image

Steps to Reproduce

Just use the latest reactor BOM and depend on latest rsocket-core and rsocket-transport-netty.

Possible Solution

I'm not very good with gradle, but I think this is the problem: https://github.com/rsocket/rsocket-java/blob/master/build.gradle#L38 I think the reactor-netty already includes the list of netty artifacts, but then you overwrite the netty-buffer dependency explicitly with an older one, instead of relying on transitive dependencies.

Your Environment

rstoyanchev commented 1 year ago

I analyzed a similar report, see https://github.com/spring-projects/spring-framework/issues/30016#issuecomment-1444138210. We need to upgrade RSocket Java to reactor-bom 2020.0.28 and Netty 4.1.89.

mdindoffer commented 1 year ago

Thanks @OlegDokuka @rstoyanchev for doing something about this. Unfortunately, although this has been closed for a month, there's been no release to try it out. Will we see 1.1.4 soon? We are still stuck on an old release of project Reactor because of this bug. Are we supposed to update to the latest and just exclude the netty-buffer dependency from RSocket? Will everything work out of the box with the latest netty binaries, or should we expect problems with this approach?