Skip to content

Fix SelectableChannel support in NioEventLoop#8344

Merged
normanmaurer merged 1 commit intonetty:4.1from
jvirtanen:register_unwrapped_selector
Oct 9, 2018
Merged

Fix SelectableChannel support in NioEventLoop#8344
normanmaurer merged 1 commit intonetty:4.1from
jvirtanen:register_unwrapped_selector

Conversation

@jvirtanen
Copy link
Copy Markdown
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
Copy Markdown

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
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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