PresentsConnection does not check that its handler is non-null before
processing messages, so let's put a (logging) NOOP handler in place when we disconnect it from the PresentsSession. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6629 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -845,15 +845,15 @@ public class PresentsSession
|
||||
}
|
||||
|
||||
// make damn sure we don't get any more messages from the old connection
|
||||
_conn.setMessageHandler(null);
|
||||
_conn.clearMessageHandler();
|
||||
}
|
||||
|
||||
// keep a handle to the new connection
|
||||
_conn = conn;
|
||||
|
||||
// tell the connection to pass messages on to us (if we're setting a connection rather than
|
||||
// clearing one out)
|
||||
// if we're setting a connection rather than clearing one out...
|
||||
if (_conn != null) {
|
||||
// tell the connection to pass messages on to us
|
||||
_conn.setMessageHandler(this);
|
||||
|
||||
// configure any active custom class loader
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.nio.channels.SocketChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import com.threerings.io.FramedInputStream;
|
||||
import com.threerings.io.FramingOutputStream;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
@@ -74,7 +76,20 @@ public class PresentsConnection extends Connection
|
||||
*/
|
||||
public void setMessageHandler (MessageHandler handler)
|
||||
{
|
||||
_handler = handler;
|
||||
_handler = Preconditions.checkNotNull(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out our message handler, causing any subsequent messages to be dropped on arrival. A
|
||||
* log message is recorded for the dropped messages.
|
||||
*/
|
||||
public void clearMessageHandler ()
|
||||
{
|
||||
_handler = new MessageHandler() {
|
||||
public void handleMessage (Message message) {
|
||||
log.info("Dropping message from cleared connection", "conn", this, "msg", message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user