harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r448773 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/VetoableChangeSupport.java test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
Date Fri, 22 Sep 2006 02:26:13 GMT
Author: pyang
Date: Thu Sep 21 19:26:12 2006
New Revision: 448773

URL: http://svn.apache.org/viewvc?view=rev&rev=448773
Log:
Apply patch for HARMONY-420 ([classlib][beans]improper listener notification in java.beans.VetoableChangeSupport)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java?view=diff&rev=448773&r1=448772&r2=448773
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
Thu Sep 21 19:26:12 2006
@@ -344,11 +344,15 @@
             PropertyChangeEvent revertEvent = createPropertyChangeEvent(
                     propName, newValue, oldValue);
             for (VetoableChangeListener listener : listensToAll) {
-                listener.vetoableChange(revertEvent);
+                try {
+                        listener.vetoableChange(revertEvent);
+                } catch (PropertyVetoException ignored){}
             }
             if (listensToOne != null) {
                 for (VetoableChangeListener listener : listensToOne) {
-                    listener.vetoableChange(revertEvent);
+                        try {
+                                listener.vetoableChange(revertEvent);
+                        } catch (PropertyVetoException ignored){}
                 }
             }
             throw pve;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java?view=diff&rev=448773&r1=448772&r2=448773
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
Thu Sep 21 19:26:12 2006
@@ -1130,6 +1130,44 @@
         assertEquals("text.default", source.getText());
     }
 
+    public void testFireVetoableChangeException_revert_event() {
+	        final VetoableChangeSupport support = new VetoableChangeSupport(new Object());
+		final StringBuffer sb = new StringBuffer();
+		final String A_IN = "a", B_IN="b", A_THROW="A", B_THROW="B";
+
+                support.addVetoableChangeListener(new VetoableChangeListener() {
+                        public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
{
+                      		sb.append(A_IN);
+                                if(sb.length() == 4) {
+					sb.append(A_THROW);
+                                        throw new PropertyVetoException(A_THROW, e);
+                                }
+                        }
+                });
+
+                
+                support.addVetoableChangeListener(new VetoableChangeListener() {
+                        public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
{
+				sb.append(B_IN);
+                                if(sb.length() == 2) {
+					sb.append(B_THROW);
+                                        throw new PropertyVetoException(B_THROW, e);
+                                }
+                        }
+                });
+
+
+                try {
+			support.fireVetoableChange("propName", 0, 1);
+                } catch(PropertyVetoException pve) {
+			assertTrue("Illegal sequence:"+sb, sb.toString().equals("abBaAb"));
+			String message = pve.getMessage();
+			assertTrue("Illegal exception:"+message, message.equals(B_THROW));
+			return;
+                }
+		assertFalse("Unreachable path:"+sb, true);
+    }
+
     /*
      * Class under test for void removeVetoableChangeListener(String,
      * VetoableChangeListener)



Mime
View raw message