From 14b8654d3a2d2ea41bdb716f0fbf62fe606cd637 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 3 Oct 2001 03:40:44 +0000 Subject: [PATCH] Modified code that calls objectAvailable() to catch exceptions thrown by the subscriber so that they don't throw monkey wrenches into anyone's business. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@382 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/server/PresentsDObjectMgr.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java index 32514dc14..3e8dca145 100644 --- a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java +++ b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java @@ -1,5 +1,5 @@ // -// $Id: PresentsDObjectMgr.java,v 1.15 2001/10/02 02:05:50 mdb Exp $ +// $Id: PresentsDObjectMgr.java,v 1.16 2001/10/03 03:40:44 mdb Exp $ package com.threerings.cocktail.cher.server; @@ -432,6 +432,21 @@ public class CherDObjectMgr implements DObjectManager return _nextOid; } + /** + * Calls {@link Subscriber#objectAvailable} and catches and logs any + * exception thrown by the subscriber during the call. + */ + protected static void informObjectAvailable (Subscriber sub, DObject obj) + { + try { + sub.objectAvailable(obj); + } catch (Exception e) { + Log.warning("Subscriber choked during object available " + + "[obj=" + obj + ", sub=" + sub + "]."); + Log.logStackTrace(e); + } + } + /** * Used to create a distributed object and register it with the * system. @@ -451,10 +466,11 @@ public class CherDObjectMgr implements DObjectManager throws ObjectAccessException { int oid = getNextOid(); + DObject obj = null; try { // create a new instance of this object - DObject obj = (DObject)_class.newInstance(); + obj = (DObject)_class.newInstance(); // initialize this object obj.setOid(oid); @@ -473,7 +489,7 @@ public class CherDObjectMgr implements DObjectManager // let the target subscriber know that their object is // available - _target.objectAvailable(obj); + informObjectAvailable(_target, obj); } } catch (Exception e) { @@ -549,7 +565,7 @@ public class CherDObjectMgr implements DObjectManager obj.addSubscriber(_target); // let them know that things are groovy - _target.objectAvailable(obj); + informObjectAvailable(_target, obj); // return false to ensure that this event is not dispatched to // the fake object's subscriber list (even though it's empty)