Fix possible NPEs from WebSocketAdapter

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-12-16 14:51:53 +11:00
parent 39585ea86e
commit ab5c72f14f
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