Skip to content

Fix SelectableChannel support in NioEventLoop #8344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2018

Conversation

jvirtanen
Copy link
Contributor

Motivation:

Unless the io.netty.noKeySetOptimization system property is set, registering a SelectableChannel instance to a NioEventLoop results in a ClassCastException:

io.netty.channel.nio.SelectedSelectionKeySetSelector cannot be cast to java.nio.channels.spi.AbstractSelector

Modifications:

Instead of selector, pass unwrappedSelector to SelectableChannel.

Result:

It is possible to register a SelectableChannel instance without setting the io.netty.noKeySetOptimization system property.

@netty-bot
Copy link

Can one of the admins verify this patch?

@jvirtanen jvirtanen force-pushed the register_unwrapped_selector branch from 35b7157 to 80981e1 Compare October 7, 2018 13:36
}
});

latch.await();
Copy link
Contributor

Choose a reason for hiding this comment

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

Await with timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That could be done, but please note that I set a timeout on the @Test annotation so that the whole test case will fail in case of a timeout.

Copy link
Contributor

Choose a reason for hiding this comment

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

Works for me.

Copy link
Member

@normanmaurer normanmaurer left a comment

Choose a reason for hiding this comment

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

Please address my comment and sign the ICLA:

https://netty.io/s/icla

Thanks a lot!


latch.await();
} finally {
group.shutdownGracefully();
Copy link
Member

Choose a reason for hiding this comment

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

Also close the channels ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Fixed.

Motivation:

Unless the 'io.netty.noKeySetOptimization' system property is set,
registering a SelectableChannel instance to a NioEventLoop results
in a ClassCastException:

    io.netty.channel.nio.SelectedSelectionKeySetSelector cannot be cast
        to java.nio.channels.spi.AbstractSelector

Modifications:

Instead of 'selector', pass 'unwrappedSelector' to SelectableChannel.

Result:

It is possible to register a SelectableChannel instance without
setting the 'io.netty.noKeySetOptimization' system property.
@jvirtanen jvirtanen force-pushed the register_unwrapped_selector branch from 80981e1 to 243b904 Compare October 8, 2018 07:55
@jvirtanen
Copy link
Contributor Author

@normanmaurer We just signed the CCLA.

@normanmaurer normanmaurer merged commit fc28bcc into netty:4.1 Oct 9, 2018
@normanmaurer normanmaurer added this to the 4.1.31.Final milestone Oct 9, 2018
@normanmaurer normanmaurer self-assigned this Oct 9, 2018
@normanmaurer
Copy link
Member

@jvirtanen merged... thx

@jvirtanen jvirtanen deleted the register_unwrapped_selector branch October 9, 2018 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants