-
Notifications
You must be signed in to change notification settings - Fork 84
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
Avoid a ClassCastException when channel is NioChildDatagramChannel. #885
Conversation
@jitsni will you review this please |
@jitsni Did you have a chance to check this one ? Thanks. |
ReadDispatcher readDispatcher = channel instanceof NioSocketChannel | ||
? new TcpReadDispatcher((NioSocketChannel) channel) | ||
: new UdpReadDispatcher((NioDatagramChannel) channel); | ||
ReadDispatcher readDispatcher = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please format and include brackets on the ifs, this is especially ugly because you indent on the if to where the bracket would be as if the else if is suppose to be under the general if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation was ok. But there were few tabs in there that messed it up in github. I don't know from where I have those tabs from time to time...
|
||
@Override | ||
public boolean dispatch(NioWorker worker, SelectionKey key) { | ||
// return worker.readUdp(key, channel.); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why have this comment
Also, it is related to #818 |
The fix avoid the ClassCastException, but I wonder if it masks any actual problem |
@@ -629,9 +626,13 @@ public void run() { | |||
int interestOps = channel.getInternalInterestOps(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need the following:
if (channel instanceof NioChildDatagramChannel) {
return;
}
It was there in the previous commits but got removed incorrectly. See the commit that removed it:
432b55c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit you gave did not affect that file. I found the change in commit 105d1c6
If I'm adding this piece of code in register and deregister, it means that I can remove all the changes that I did ? I'll try to check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran some tests, it seems that your suggested change is fixing the issue without requiring the changes I did. I suggest to close this PR without merging and opening a new one only with those changes.
Closing this one as a new PR will address the issue. |
Adding a dummy ReadDispatcher specific for NioChildDatagramChannel. Its dispatch() method is never called.