Thread.dumpStack() circumvents whatever logging is configured and writes

directly to stderr. Logging an exception with the associated warning does the
right thing and logs the stack trace via the logging system.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5318 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-08-13 17:35:37 +00:00
parent b323bf6bf9
commit fcedbe90d7
16 changed files with 60 additions and 95 deletions
@@ -306,8 +306,8 @@ public class ClientManager
{
ClientObject clobj = _objmap.get(username);
if (clobj == null) {
log.warning("Requested to release unmapped client object [username=" + username + "].");
Thread.dumpStack();
log.warning("Requested to release unmapped client object", "username", username,
new Exception());
return;
}
@@ -334,8 +334,8 @@ public class ClientManager
{
ClientObject clobj = _objmap.remove(oldname);
if (clobj == null) {
log.warning("Requested to rename unmapped client object [username=" + oldname + "].");
Thread.dumpStack();
log.warning("Requested to rename unmapped client object", "username", oldname,
new Exception());
return false;
}
_objmap.put(newname, clobj);
@@ -409,8 +409,7 @@ public class ClientManager
client.connectionFailed(fault);
} else if (!(conn instanceof AuthingConnection)) {
log.info("Unmapped connection failed? [conn=" + conn + ", fault=" + fault + "].");
Thread.dumpStack();
log.info("Unmapped connection failed?", "conn", conn, "fault", fault, new Exception());
}
}
@@ -165,15 +165,13 @@ public class InvocationManager
_omgr.requireEventThread(); // sanity check
if (marsh == null) {
log.warning("Refusing to unregister null marshaller.");
Thread.dumpStack();
log.warning("Refusing to unregister null marshaller.", new Exception());
return;
}
if (_dispatchers.remove(marsh.getInvocationCode()) == null) {
log.warning("Requested to remove unregistered marshaller? " +
"[marsh=" + marsh + "].");
Thread.dumpStack();
"[marsh=" + marsh + "].", new Exception());
}
}
@@ -21,8 +21,6 @@
package com.threerings.presents.server;
import com.samskivert.util.StringUtil;
import com.threerings.presents.client.InvocationReceiver.Registration;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.InvocationNotificationEvent;
@@ -57,14 +55,13 @@ public abstract class InvocationSender
// specific client
Registration rreg = target.receivers.get(receiverCode);
if (rreg == null) {
log.warning("Unable to locate receiver for invocation service notification " +
"[clobj=" + target.who() + ", code=" + receiverCode +
", methId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
Thread.dumpStack();
log.warning("Unable to locate receiver for invocation service notification",
"clobj", target.who(), "code", receiverCode, "methId", methodId,
"args", args, new Exception());
} else {
// Log.info("Sending notification [target=" + target + ", code=" + receiverCode +
// ", methodId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
// log.info("Sending notification", "target", target, "code", receiverCode,
// "methodId", methodId, "args", args);
// create and dispatch an invocation notification event
target.postEvent(
@@ -874,8 +874,8 @@ public class PresentsClient
public void eventReceived (DEvent event)
{
if (event instanceof PresentsDObjectMgr.AccessObjectEvent) {
log.warning("Ignoring event that shouldn't be forwarded " + event + ".");
Thread.dumpStack();
log.warning("Ignoring event that shouldn't be forwarded " + event + ".",
new Exception());
return;
}
@@ -218,9 +218,8 @@ public class PresentsDObjectMgr
public <T extends DObject> T registerObject (T object)
{
if (_dobjThread != null && !isDispatchThread()) {
log.warning("Registering DObject on non-dobject thread: " +
"[class=" + object.getClass().getName() + "]");
Thread.dumpStack();
log.warning("Registering DObject on non-dobject thread",
"class", object.getClass().getName(), new Exception());
}
int oid = getNextOid();
@@ -166,8 +166,7 @@ public abstract class Connection implements NetEventHandler
{
// we shouldn't be closed twice
if (isClosed()) {
log.warning("Attempted to re-close connection " + this + ".");
Thread.dumpStack();
log.warning("Attempted to re-close connection " + this + ".", new Exception());
return;
}
@@ -186,8 +185,7 @@ public abstract class Connection implements NetEventHandler
{
// if we're already closed, then something is seriously funny
if (isClosed()) {
log.warning("Failure reported on closed connection " + this + ".");
Thread.dumpStack();
log.warning("Failure reported on closed connection " + this + ".", new Exception());
return;
}
@@ -847,16 +847,14 @@ public class ConnectionManager extends LoopingThread
{
// sanity check
if (conn == null || msg == null) {
log.warning("postMessage() bogosity [conn=" + conn + ", msg=" + msg + "].");
Thread.dumpStack();
log.warning("postMessage() bogosity", "conn", conn, "msg", msg, new Exception());
return;
}
// more sanity check; messages must only be posted from the dobjmgr thread
if (!_omgr.isDispatchThread()) {
log.warning("Message posted on non-distributed object thread [conn=" + conn +
", msg=" + msg + ", thread=" + Thread.currentThread() + "].");
Thread.dumpStack();
log.warning("Message posted on non-distributed object thread", "conn", conn,
"msg", msg, "thread", Thread.currentThread(), new Exception());
// let it through though as we don't want to break things unnecessarily
}