-
Notifications
You must be signed in to change notification settings - Fork 323
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
Processor#run() 方法的改进的一个建议 #57
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Processor#run()
有如下的一个代码片段:这里是先判断了
isReadable()
、isWritable()
, 最后判断的key.isValid()
, 这里最好应该先判断key.isValid()
. 在判断isReadable()
、isWritable()
.因为在判断isReadable()
、isWritable()
之前key
已经无效了, 所以可能会产生CancelledKeyException
.虽然在catch
中最终会捕获到这个异常, 但是按照比较好的方式做的话, 应该还是先判断key.isValid()
会更好一点.The text was updated successfully, but these errors were encountered: