From 4f9bf920b05fc0d30e873c0e0f9012b2fbde4bc3 Mon Sep 17 00:00:00 2001 From: shaper Date: Fri, 13 Dec 2002 00:48:19 +0000 Subject: [PATCH] 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 --- .../java/com/samskivert/util/ObserverList.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ObserverList.java b/projects/samskivert/src/java/com/samskivert/util/ObserverList.java index e67b88e7..7645577d 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ObserverList.java +++ b/projects/samskivert/src/java/com/samskivert/util/ObserverList.java @@ -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