Log a warning and dump the stack rather than throwing an exception if we

try to add an observer more than once and we're not allowing duplicate
observers so that existing callers to add() don't have the proverbial rug
yanked out from underneath them.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@989 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
shaper
2002-12-13 00:48:19 +00:00
parent e59acac67e
commit 4f9bf920b0
@@ -1,5 +1,5 @@
//
// $Id: ObserverList.java,v 1.4 2002/12/12 23:55:56 shaper Exp $
// $Id: ObserverList.java,v 1.5 2002/12/13 00:48:19 shaper Exp $
package com.samskivert.util;
@@ -146,13 +146,15 @@ public class ObserverList extends ArrayList
{
// make sure we're not violating the list constraints
if (!_allowDups && contains(o)) {
throw new RuntimeException(
"Observer attempted to observe list it's already observing! " +
"[obs=" + o + "].");
}
Log.warning("Observer attempted to observe list it's already " +
"observing! [obs=" + o + "].");
Thread.dumpStack();
return false;
// go ahead and add the observer
return super.add(o);
} else {
// go ahead and add the observer
return super.add(o);
}
}
// documentation inherited