401177 - Make org.eclipse.jetty.websocket.api.WebSocketAdapter threadsafe

+ Making some subtle changes to address thread safety of the WebSocketAdapter
This commit is contained in:
Joakim Erdfelt 2013-02-21 07:30:28 -07:00
parent ea0996f63a
commit 246db2b08d
1 changed files with 7 additions and 4 deletions

View File

@ -25,11 +25,12 @@ package org.eclipse.jetty.websocket.api;
*/
public class WebSocketAdapter implements WebSocketListener
{
private Session session;
private volatile Session session;
public RemoteEndpoint getRemote()
{
return session.getRemote();
Session sess = this.session;
return sess == null?null:session.getRemote();
}
public Session getSession()
@ -39,12 +40,14 @@ public class WebSocketAdapter implements WebSocketListener
public boolean isConnected()
{
return (session != null) && (session.isOpen());
Session sess = this.session;
return (sess != null) && (sess.isOpen());
}
public boolean isNotConnected()
{
return (session == null) || (!session.isOpen());
Session sess = this.session;
return (sess == null) || (!sess.isOpen());
}
@Override