Wrote code to help automatically detect bugs.

Have invocation marshallers track whether someone ever ended up responding
to the client: if they get garbage collected without ever doing so
(and they're not the base class InvocationMarshaller, which can only report
errors), log an informative error message.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3792 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2005-12-21 02:10:38 +00:00
parent 5a57753d84
commit 4cb18bd5ab
3 changed files with 31 additions and 0 deletions
@@ -70,9 +70,19 @@ public class InvocationMarshaller
* responses. This is only valid on the server. */
public transient DObjectManager omgr;
/**
* Set an identifier for the invocation that this listener
* is used for, so we can report it if we are never responded-to.
*/
public void setInvocationId (String name)
{
_invId = name;
}
// documentation inherited from interface
public void requestFailed (String cause)
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, REQUEST_FAILED_RSPID,
new Object[] { cause }));
@@ -103,6 +113,20 @@ public class InvocationMarshaller
return "[callerOid=" + callerOid + ", reqId=" + requestId +
", type=" + getClass().getName() + "]";
}
// documentation inherited
protected void finalize ()
throws Throwable
{
if (_invId != null && getClass() != ListenerMarshaller.class) {
Log.warning("Invocation listener never responded to: " +
_invId);
}
super.finalize();
}
/** On the server, the id of the invocation method. */
protected transient String _invId;
}
/**
@@ -118,6 +142,7 @@ public class InvocationMarshaller
// documentation inherited from interface
public void requestProcessed ()
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, REQUEST_PROCESSED,
null));
@@ -150,6 +175,7 @@ public class InvocationMarshaller
// documentation inherited from interface
public void requestProcessed (Object result)
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, REQUEST_PROCESSED,
new Object[] { result }));
@@ -256,6 +256,10 @@ public class InvocationManager
// dispatch the request
try {
if (rlist != null) {
rlist.setInvocationId(StringUtil.shortClassName(disp) +
", methodId=" + methodId);
}
disp.dispatchRequest(source, methodId, args);
} catch (InvocationException ie) {
@@ -27,6 +27,7 @@ public class ${name}Marshaller extends InvocationMarshaller
// documentation inherited from interface
public void $lm.method.name ($lm.getArgList(false))
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, $lm.code,
new Object[] { $lm.getWrappedArgList(false) }));