Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -300,12 +300,24 @@ private static Map.Entry<ChannelOption<?>, Object>[] buildChannelOptions(AsyncHt
* Applies the pre-resolved channel options to a freshly created channel. Invoked from the channel initializer
* (once per connection, on the channel's event loop, before the channel is connected), mirroring what
* {@link Bootstrap#option} would otherwise do but without the shared, synchronized options map.
* <p>
* The per-option handling mirrors Netty's {@code AbstractBootstrap#setChannelOption}: an unknown option is
* warned about and skipped, and a failure to set an option is warned about and rethrown so the channel is
* closed rather than connecting with a half-applied configuration.
*/
@SuppressWarnings("unchecked")
private void applyChannelOptions(Channel channel) {
ChannelConfig channelConfig = channel.config();
for (Map.Entry<ChannelOption<?>, Object> option : channelOptions) {
channelConfig.setOption((ChannelOption<Object>) option.getKey(), option.getValue());
ChannelOption<Object> key = (ChannelOption<Object>) option.getKey();
try {
if (!channelConfig.setOption(key, option.getValue())) {
LOGGER.warn("Unknown channel option '{}' for channel '{}'", key, channel);
}
} catch (Throwable t) {
LOGGER.warn("Failed to set channel option '{}' with value '{}' for channel '{}'", key, option.getValue(), channel, t);
throw t;
}
}
}

Expand Down
Loading