Fix possible NPEs from WebSocketAdapter
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
39585ea86e
commit
ab5c72f14f
|
@ -21,10 +21,11 @@ package org.eclipse.jetty.websocket.api;
|
||||||
public class WebSocketAdapter implements WebSocketListener
|
public class WebSocketAdapter implements WebSocketListener
|
||||||
{
|
{
|
||||||
private volatile Session session;
|
private volatile Session session;
|
||||||
|
private RemoteEndpoint remote;
|
||||||
|
|
||||||
public RemoteEndpoint getRemote()
|
public RemoteEndpoint getRemote()
|
||||||
{
|
{
|
||||||
return session.getRemote();
|
return remote;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session getSession()
|
public Session getSession()
|
||||||
|
@ -34,7 +35,8 @@ public class WebSocketAdapter implements WebSocketListener
|
||||||
|
|
||||||
public boolean isConnected()
|
public boolean isConnected()
|
||||||
{
|
{
|
||||||
return session.isOpen();
|
Session sess = this.session;
|
||||||
|
return (sess != null) && (sess.isOpen());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNotConnected()
|
public boolean isNotConnected()
|
||||||
|
@ -58,6 +60,7 @@ public class WebSocketAdapter implements WebSocketListener
|
||||||
public void onWebSocketConnect(Session sess)
|
public void onWebSocketConnect(Session sess)
|
||||||
{
|
{
|
||||||
this.session = sess;
|
this.session = sess;
|
||||||
|
this.remote = sess.getRemote();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue