chore: add a channel initializer that only sets supported options #1130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Netty prints out a warning when trying to set channel options that are not supported by a transport (only for options added by the (server-) bootstrap). This is no big deal as the warning can be ignored, but there are some users which are reporting it as an issue.
Modification
Add a new channel initializer that holds the options that should be added to a channel and only sets them if they are supported by the channel that gets initialized. This is the best way to solve the issue, as there is no other way to check if an option is supported. Although some options are bound to epoll or kqueue, it might get over complicated when checking based on that, especially considering the addition of the io_uring transport that is coming into netty main with the next release.
Result
No more warnings that there was a try to set channel options that are not supported by the channel.