Complain loudly about listeners or subscribers that try to add themselves
more than once. Use testAndAddEqual() where appropriate now that testAndAdd() doesn't use object equality. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2056 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DObject.java,v 1.54 2002/11/10 01:43:28 mdb Exp $
|
// $Id: DObject.java,v 1.55 2002/12/12 00:30:47 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.dobj;
|
package com.threerings.presents.dobj;
|
||||||
|
|
||||||
@@ -115,8 +115,14 @@ public class DObject implements Streamable
|
|||||||
// only add the subscriber if they're not already there
|
// only add the subscriber if they're not already there
|
||||||
Object[] subs = ListUtil.testAndAdd(_subs, sub);
|
Object[] subs = ListUtil.testAndAdd(_subs, sub);
|
||||||
if (subs != null) {
|
if (subs != null) {
|
||||||
|
// Log.info("Adding subscriber " + which() + ": " + sub + ".");
|
||||||
_subs = subs;
|
_subs = subs;
|
||||||
_scount++;
|
_scount++;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.warning("Refusing subscriber that's already in the list " +
|
||||||
|
"[dobj=" + which() + ", subscriber=" + sub + "]");
|
||||||
|
Thread.dumpStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +176,12 @@ public class DObject implements Streamable
|
|||||||
Object[] els = ListUtil.testAndAdd(_listeners, listener);
|
Object[] els = ListUtil.testAndAdd(_listeners, listener);
|
||||||
if (els != null) {
|
if (els != null) {
|
||||||
_listeners = els;
|
_listeners = els;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// complain if an object requests to add itself more than once
|
||||||
|
Log.warning("Refusing listener that's already in the list " +
|
||||||
|
"[dobj=" + which() + ", listener=" + listener + "]");
|
||||||
|
Thread.dumpStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +244,7 @@ public class DObject implements Streamable
|
|||||||
{
|
{
|
||||||
// check for the existence of the lock in the list and add it if
|
// check for the existence of the lock in the list and add it if
|
||||||
// it's not already there
|
// it's not already there
|
||||||
Object[] list = ListUtil.testAndAdd(_locks, name);
|
Object[] list = ListUtil.testAndAddEqual(_locks, name);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
// a null list means the object was already in the list
|
// a null list means the object was already in the list
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user