harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r399213 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/PropertyChangeSupport.java test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
Date Wed, 03 May 2006 08:59:08 GMT
Author: mloenko
Date: Wed May  3 01:58:58 2006
New Revision: 399213

URL: http://svn.apache.org/viewcvs?rev=399213&view=rev
Log:
fixes for HARMONY-320
PropertyChangeSupport.removePropertyChangeListener(PropertyChangeListener) doesn't remove
a specific property listener

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java?rev=399213&r1=399212&r2=399213&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
Wed May  3 01:58:58 2006
@@ -161,14 +161,15 @@
     public synchronized void removePropertyChangeListener(
             PropertyChangeListener listener) {
         if (listener != null) {
-            Iterator iterator = allPropertiesChangeListeners.iterator();
-            while (iterator.hasNext()) {
-                PropertyChangeListener pcl =
-                    (PropertyChangeListener) iterator.next();
-                if (pcl == listener) {
-                    iterator.remove();
-                    break;
-                }
+            if (listener instanceof PropertyChangeListenerProxy) {
+                String name = ((PropertyChangeListenerProxy) listener)
+                        .getPropertyName();
+                PropertyChangeListener lst = (PropertyChangeListener) ((PropertyChangeListenerProxy)
listener)
+                        .getListener();
+
+                removePropertyChangeListener(name, lst);
+            } else {
+                allPropertiesChangeListeners.remove(listener);
             }
         }
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java?rev=399213&r1=399212&r2=399213&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
Wed May  3 01:58:58 2006
@@ -100,6 +100,28 @@
     
     
     /**
+     * @tests java.beans.PropertyChangeSupport#removePropertyChangeListener(
+     *        java.lang.String, java.beans.PropertyChangeListener)
+     */
+    public void testRemovePropertyChangeListener2() {
+        // Regerssion for HARMONY-320
+        PropertyChangeListener listener = new PropertyChangeListener() {
+            public void propertyChange(PropertyChangeEvent arg0) {}
+        };
+
+        PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+        pcs.addPropertyChangeListener("property", listener);
+        PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
+        assertEquals(1, listeners.length);
+
+        pcs.removePropertyChangeListener(listeners[0]);
+        listeners = pcs.getPropertyChangeListeners();
+        assertEquals(0, listeners.length);
+    } 
+    
+    
+    /**
      * The test checks the serialization for listeners supporting serialization
      */
     public void testSerializableListener() {



Mime
View raw message