Skip to content
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

aio-core 1.5.31 版本会提示这个错 #12

Open
zkname opened this issue Sep 27, 2023 · 2 comments
Open

aio-core 1.5.31 版本会提示这个错 #12

zkname opened this issue Sep 27, 2023 · 2 comments

Comments

@zkname
Copy link

zkname commented Sep 27, 2023

不确定是哪里多线程同时操作了?

是不是需要selectionKey.isValid() 先判断一下?

java.nio.channels.CancelledKeyException
        at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73)
        at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:77)
        at org.smartboot.socket.enhance.EnhanceAsynchronousChannelGroup.removeOps(EnhanceAsynchronousChannelGroup.java:122)
        at org.smartboot.socket.enhance.EnhanceAsynchronousServerChannel.doRead(EnhanceAsynchronousServerChannel.java:273)
        at org.smartboot.socket.enhance.EnhanceAsynchronousChannelGroup.lambda$new$0(EnhanceAsynchronousChannelGroup.java:76)
        at org.smartboot.socket.enhance.EnhanceAsynchronousChannelGroup$Worker.run(EnhanceAsynchronousChannelGroup.java:219)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
@smthing
Copy link
Contributor

smthing commented Sep 27, 2023

有没有复现代码

@zkname
Copy link
Author

zkname commented Oct 8, 2023

有没有复现代码

生产环境运行的啊。
EnhanceAsynchronousChannelGroup.java:122 判断一下 key是否有效,改成这样可以吗?

    public static void removeOps(SelectionKey selectionKey, int opt) {
        if (selectionKey.isValid() && (selectionKey.interestOps() & opt) != 0) {
            selectionKey.interestOps(selectionKey.interestOps() & ~opt);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants