Skip to content

Conversation

@j-bahr
Copy link
Contributor

@j-bahr j-bahr commented Jan 25, 2026

LoopResources.onChannel() and onChannelClass() incorrectly selected channel factories when users provided custom EventLoopGroups via runOn(). The previous logic only checked if DefaultLoopNativeDetector.INSTANCE (the highest-priority available transport) supported the group, falling back to NIO otherwise.

This caused issues when, for example, io_uring was the default transport but a user explicitly provided an Epoll EventLoopGroup - the code would incorrectly return NIO channel factories instead of Epoll ones.

Changes:

  • Add forGroup(EventLoopGroup) method to DefaultLoopNativeDetector that checks all available transports (io_uring, epoll, kqueue, nio) to find the correct channel factory for any given EventLoopGroup
  • Fix DefaultLoopNIO.supportGroup() to properly detect NIO event loops using isCompatible(NioIoHandle.class), matching the pattern used by other transports
  • Update onChannel() and onChannelClass() to use forGroup() instead of the previous INSTANCE-or-NIO logic

@j-bahr j-bahr force-pushed the io_uring-fix branch 6 times, most recently from 1318feb to e1dbd40 Compare January 25, 2026 19:59
`LoopResources.onChannel()` and `onChannelClass()` incorrectly selected channel factories when users provided custom `EventLoopGroups` via `runOn()`. The previous logic only checked if `DefaultLoopNativeDetector.INSTANCE` (the highest-priority available transport) supported the group, falling back to `NIO` otherwise.

This caused issues when, for example, `io_uring` was the default transport but a user explicitly provided an `Epoll` `EventLoopGroup` - the code would incorrectly return `NIO` channel factories instead of `Epoll` ones.

Changes:
  - Add forGroup(EventLoopGroup) method to `DefaultLoopNativeDetector` that checks all available transports (`io_uring`, `epoll`, `kqueue`, `nio`) to find the correct channel factory for any given `EventLoopGroup`
  - Fix `DefaultLoopNIO.supportGroup()` to properly detect `NIO` event loops using `isCompatible(NioIoHandle.class)`, matching the pattern used by other transports
  - Update `onChannel()` and `onChannelClass()` to use `forGroup()` instead of the previous INSTANCE-or-NIO logic

Signed-off-by: Jeff Bahr <[email protected]>
Comment on lines +80 to +84
if (NIO.supportGroup(group)) {
return NIO;
}
// Fallback to NIO for unknown group types
return NIO;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether NIO supports the ELG or not, we will return NIO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do an exhaustive search above so the other option would be to throw an exception that no DefaultLoop was found for the given EventLoopGroup. This would only break if a new EventLoopGroup type is added in the future. What do you suggest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes let's throw

@j-bahr
Copy link
Contributor Author

j-bahr commented Jan 26, 2026

@violetagg I had to make a number of changes to the gradle build file to get the multi release jar support to work in tests. I'm not an expert with gradle so feel free to comment or make changes if you are not happy with what I did. Thanks.

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.

2 participants