Skip to content

HttpClient resolver gets changed after configuring an event loop with runOn #1655

@fcofdez

Description

@fcofdez

When configuring a custom event loop for the http client, it overrides a previously configured resolver, see reactor.netty.transport.ClientTransport#runOn

Expected Behavior

Keep the configured resolver when a custom event loop is used. Additionally, I would like to avoid instantiating a default resolver that's outside of the client control.

Actual Behavior

The resolver gets replaced by a default implementation.

Steps to Reproduce

@Test
public void repoCase() {
        final EventLoopGroup eventLoopGroup = new NioEventLoopGroup(1);
       HttpClient.create(connectionProvider)
                 .resolver(DefaultAddressResolverGroup.INSTANCE)
                 .runOn(eventLoopGroup); --> This creates a new resolver
}

Possible Solution

reactor.netty.transport.ClientTransport#runOn

	@Override
	public T runOn(LoopResources loopResources, boolean preferNative) {
		T dup = super.runOn(loopResources, preferNative);
		CONF conf = dup.configuration();
                 if (conf.resolver != null) {
                     return dup;
                 }
		if (conf.nameResolverProvider != null) {
			conf.resolver = conf.nameResolverProvider.newNameResolverGroup(conf.loopResources(), conf.preferNative);
		}
		else {
			conf.resolver = ClientTransportConfig.DEFAULT_NAME_RESOLVER_PROVIDER
					.newNameResolverGroup(conf.loopResources(), conf.preferNative);
		}
		return dup;
	}

Your Environment

  • Reactor version(s) used: 1.0.6
  • Other relevant libraries versions (eg. netty, ...):
  • JVM version (java -version):
  • OS and version (eg. uname -a):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions