Skip to content

Conversation

@jruaux
Copy link
Contributor

@jruaux jruaux commented Dec 16, 2025

Description

This PR fixes the incomplete Netty 4.2 migration for NIO event loop creation.

After upgrading to Netty 4.2 in #3405, the NIO event loop creation in DefaultEventLoopGroupProvider still used the old Netty 4.1 API (new NioEventLoopGroup()), which creates event loops incompatible with applications using Netty 4.2's new IO model.

Changes

  • Created NioProvider: Following the same pattern as EpollProvider, KqueueProvider, and IOUringProvider
  • Updated DefaultEventLoopGroupProvider: Now uses NioProvider.getResources() to create NIO event loop groups
  • Uses Netty 4.2 API: Creates event loops using MultiThreadIoEventLoopGroup with NioIoHandler.newFactory()

Impact

This ensures that NIO event loop creation is consistent with the other transports and compatible with Netty 4.2's new IO model. Applications using Netty 4.2 event loops will no longer encounter IllegalStateException: incompatible event loop type errors when using Lettuce.

Testing

  • Code compiles successfully
  • Existing tests pass (will be verified by CI)
  • No new tests needed (internal implementation change)

Fixes #3584

After upgrading to Netty 4.2 in #3405, the NIO event loop creation in
DefaultEventLoopGroupProvider still used the old Netty 4.1 API
(new NioEventLoopGroup()), which creates event loops incompatible with
applications using Netty 4.2's new IO model.

This commit introduces NioProvider following the same pattern as
EpollProvider, KqueueProvider, and IOUringProvider. The provider creates
NIO event loop groups using MultiThreadIoEventLoopGroup with
NioIoHandler.newFactory(), ensuring compatibility with Netty 4.2.

Fixes #3584
The test was expecting NioEventLoopGroup but now we return
MultiThreadIoEventLoopGroup (Netty 4.2 API). Updated the test to use
EventLoopGroup interface instead of the concrete type.
@jruaux
Copy link
Contributor Author

jruaux commented Dec 16, 2025

Fixed the test failure. The issue was that DefaultEventLoopGroupProviderUnitTests was expecting NioEventLoopGroup but now we return MultiThreadIoEventLoopGroup (Netty 4.2 API). Updated the test to use the EventLoopGroup interface instead of the concrete type.

The fix is backward compatible - the test still requests NioEventLoopGroup.class but accepts any EventLoopGroup implementation.

…3584

Updated tests to use MultithreadEventLoopGroup instead of NioEventLoopGroup
for variables that need to call executorCount(). The allocate() method now
returns MultiThreadIoEventLoopGroup (Netty 4.2 API) instead of
NioEventLoopGroup.
@jruaux
Copy link
Contributor Author

jruaux commented Dec 16, 2025

Fixed another test file (DefaultClientResourcesUnitTests) that had the same issue. The tests that call executorCount() now use MultithreadEventLoopGroup type (which has this method) instead of NioEventLoopGroup.

@jruaux
Copy link
Contributor Author

jruaux commented Dec 16, 2025

✅ All CI checks are now passing!

The PR is ready for review.

Summary of changes:

  1. Created NioProvider.java - Implements Netty 4.2 API for NIO event loops using MultiThreadIoEventLoopGroup with NioIoHandler.newFactory()
  2. Updated DefaultEventLoopGroupProvider.java - Uses NioProvider instead of directly instantiating NioEventLoopGroup
  3. Fixed test files to handle the new return type (MultiThreadIoEventLoopGroup instead of NioEventLoopGroup)

This ensures Lettuce is fully compatible with Netty 4.2's new IO model and eliminates the IllegalStateException: incompatible event loop type errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NIO event loop creation not updated for Netty 4.2 API

2 participants