Merge pull request #7294 from eclipse/jetty-10.0.x-7293-WS_NPE

Fix possible NPE from WebSocketAdapter
This commit is contained in:
Lachlan 2021-12-17 08:51:29 +11:00 committed by GitHub
commit 80b15ce8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -21,10 +21,11 @@ package org.eclipse.jetty.websocket.api;
public class WebSocketAdapter implements WebSocketListener
{
private volatile Session session;
private RemoteEndpoint remote;
public RemoteEndpoint getRemote()
{
return session.getRemote();
return remote;
}
public Session getSession()
@ -34,7 +35,8 @@ public class WebSocketAdapter implements WebSocketListener
public boolean isConnected()
{
return session.isOpen();
Session sess = this.session;
return (sess != null) && (sess.isOpen());
}
public boolean isNotConnected()
@ -58,6 +60,7 @@ public class WebSocketAdapter implements WebSocketListener
public void onWebSocketConnect(Session sess)
{
this.session = sess;
this.remote = sess.getRemote();
}
@Override