From 4cb18bd5abe4798f77ff64204241fa031e1ecbae Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 21 Dec 2005 02:10:38 +0000 Subject: [PATCH] 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 --- .../presents/data/InvocationMarshaller.java | 26 +++++++++++++++++++ .../presents/server/InvocationManager.java | 4 +++ .../threerings/presents/tools/marshaller.tmpl | 1 + 3 files changed, 31 insertions(+) diff --git a/src/java/com/threerings/presents/data/InvocationMarshaller.java b/src/java/com/threerings/presents/data/InvocationMarshaller.java index 92dea2943..91e593314 100644 --- a/src/java/com/threerings/presents/data/InvocationMarshaller.java +++ b/src/java/com/threerings/presents/data/InvocationMarshaller.java @@ -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 })); diff --git a/src/java/com/threerings/presents/server/InvocationManager.java b/src/java/com/threerings/presents/server/InvocationManager.java index 5054960b6..118012c7e 100644 --- a/src/java/com/threerings/presents/server/InvocationManager.java +++ b/src/java/com/threerings/presents/server/InvocationManager.java @@ -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) { diff --git a/src/java/com/threerings/presents/tools/marshaller.tmpl b/src/java/com/threerings/presents/tools/marshaller.tmpl index 54d6f415a..f14f8b053 100644 --- a/src/java/com/threerings/presents/tools/marshaller.tmpl +++ b/src/java/com/threerings/presents/tools/marshaller.tmpl @@ -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) }));