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
AsynchronousTlsChannelGroup#processPendingInterests can throw CancelledKeyException #18
Comments
Hi Jeff, thanks for the report. I tried a bit but could not reproduce the problem. However, what you suggests makes sense and is completely consistent with the other catch we already have, so I just added it. It's in master already. Best regards. |
Why is this exception ignored? There's probably an assumption involved there. Can this be officially explained in docs somewhere? |
@martinandersson Below is my explanation of the problem and the fix. The method
If we now look at
This means that Thus, depending on how Two approaches are possible:
The second approach seems (maybe surprisingly) more optimal in this case because it is both simpler and introduces smaller performance overhead assuming that |
Oh, I can only agree. Exceptions are most definitely a valid branching mechanism. I use it myself from time to time. If you ask me, I think any performance degradation - if t here is any - is probably negligible and should not really matter other than how we design our API. For example I would give my users a method |
The Selector API is already racy here. But a lot of "closing workflows" are racy and benign, as typically not much happens after a close to matter anyway. Something that would help: having a test that show non-deterministic behavior due to this race. |
In tests of the MongoDB Java driver that use this library, I've seen occasional, non-deterministic failures where
AsynchronousTlsChannelGroup#processPendingInterests
throwsCancelledKeyException
, causingAsynchronousTlsChannelGroup.loop
to exit. It happens in cases where we are forcing the server to close the socket in order to test failure scenarios.I'm not exactly sure why this is happening, but I do see that in
AsynchronousTlsChannelGroup.loop
there is already code that wraps calls tojava.nio.channels.SelectionKey#interestOps(int)
in a try/catch ofCancelledKeyException
. Does it make sense to do a similar thing inAsynchronousTlsChannelGroup#processPendingInterests
, e.g.The text was updated successfully, but these errors were encountered: