Skip to content

Phase 1: NIO event loop creation not updated for Netty 4.2 API #3584

@jruaux

Description

@jruaux

Bug Report

Current Behavior

After upgrading to Netty 4.2 in #3405, the NIO event loop creation in DefaultEventLoopGroupProvider still uses the old Netty 4.1 API:

if (NioEventLoopGroup.class.equals(type)) {
    return new NioEventLoopGroup(numberOfThreads, factoryProvider.getThreadFactory("lettuce-nioEventLoop"));
}

This creates event loops that are incompatible with applications using Netty 4.2's new IO model (MultiThreadIoEventLoopGroup with NioIoHandler).

Error

When an application uses Netty 4.2 event loops and Lettuce creates its own NIO event loops using the old API, the following error occurs:

java.lang.IllegalStateException: incompatible event loop type: io.netty.channel.SingleThreadIoEventLoop
    at io.netty.channel.AbstractChannel$AbstractUnsafe.register(AbstractChannel.java:332)
    at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:119)
    ...
    at io.lettuce.core.AbstractRedisClient.initializeChannelAsync(AbstractRedisClient.java:367)
    at io.lettuce.core.RedisClient.connectStatefulAsync(RedisClient.java:330)

Expected Behavior

NIO event loop creation should use the new Netty 4.2 API, similar to how Epoll, Kqueue, and IOUring providers were updated in #3405:

if (NioEventLoopGroup.class.equals(type)) {
    return new MultiThreadIoEventLoopGroup(numberOfThreads, 
        factoryProvider.getThreadFactory("lettuce-nioEventLoop"), 
        NioIoHandler.newFactory());
}

Environment

  • Lettuce version: 7.2.1+ (after Netty 4.2 upgrade)
  • Netty version: 4.2.5.Final
  • JDK version: 17+

Additional Context

The Netty 4.2 upgrade in #3405 updated the native transports (Epoll, Kqueue, IOUring) to use the new API but missed the NIO transport. This creates an inconsistency where:

  • Native transports work correctly with Netty 4.2
  • NIO transport still uses Netty 4.1 API and is incompatible with applications using Netty 4.2

I'm happy to submit a PR to fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    size: small1 to 2 development weeks

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions