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

NettyWebSocket.isOpen() fails with NullPointerException. #136

Open
YaroslavSaakyan opened this issue Aug 14, 2018 · 2 comments
Open

NettyWebSocket.isOpen() fails with NullPointerException. #136

YaroslavSaakyan opened this issue Aug 14, 2018 · 2 comments

Comments

@YaroslavSaakyan
Copy link

YaroslavSaakyan commented Aug 14, 2018

I use Nettosphere 2.4.10 with Atmosphere 2.4.24. I need to close Atmosphere resource on some conditions, but webSocket.isOpen() call inside of AtmosphereResourceImpl.close() method fails with NullPointerException.

    @Override
    public void close() throws IOException {
        event.setCloseByApplication(true);
        notifyListeners();
        cancel();
        if (webSocket != null && webSocket.isOpen()) {
            webSocket.close();
        }
    }

NettyWebSocket implementation of WebSocket is used. isOpen() method calls this.channel.isOpen(), but channel field is set to null after cancel() execution. After debugging I found that the reason is a change in org.atmosphere.nettosphere.BridgeRuntime.channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) method. It calls webSocket.recycle() which sets channel field to null. Looks like it was added in version 2.4.8.

@jfarcand
Copy link
Member

@YaroslavSaakyan Good job! Can you create a pull request? I will then cut a new release.

@YaroslavSaakyan
Copy link
Author

@jfarcand Ok, I'll try to do it this week.

YaroslavSaakyan added a commit to YaroslavSaakyan/nettosphere that referenced this issue Sep 22, 2018
YaroslavSaakyan added a commit to YaroslavSaakyan/nettosphere that referenced this issue Dec 25, 2018
Revert "Atmosphere#136 - Remove setting channel to null in NettyWebSocket#recycle()."

This reverts commit 73c8792.
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