You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/05/05 07:47:53 UTC

svn commit: r399976 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/VetoableChangeSupport.java test/java/org/apache/harmony/tests/java/beans/VetoableChangeSupportTest.java

Author: mloenko
Date: Thu May  4 22:47:53 2006
New Revision: 399976

URL: http://svn.apache.org/viewcvs?rev=399976&view=rev
Log:
fixes for HARMONY-421
java.beans.VetoableChangeSupport.readObject() throws unexpected ClassCastException

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/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/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java?rev=399976&r1=399975&r2=399976&view=diff
==============================================================================
--- 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 May  4 22:47:53 2006
@@ -270,20 +270,18 @@
     /**
      * @com.intel.drl.spec_ref
      */
-    private void readObject(ObjectInputStream ois)
-            throws IOException, ClassNotFoundException {
-        allVetoableChangeListeners = (ArrayList) ois.readObject();
-        selectedVetoableChangeListeners = (HashMap) ois.readObject();
-        
+    private void readObject(ObjectInputStream ois) throws IOException,
+            ClassNotFoundException {
+
         children = (Hashtable) ois.readObject();
-        
+
         selectedVetoableChangeListeners = new HashMap(children);
-        allVetoableChangeListeners =
-                (ArrayList) selectedVetoableChangeListeners.remove("");
-        if(allVetoableChangeListeners == null) {
+        allVetoableChangeListeners = (ArrayList) selectedVetoableChangeListeners
+                .remove("");
+        if (allVetoableChangeListeners == null) {
             allVetoableChangeListeners = new ArrayList();
         }
-        
+
         sourceBean = ois.readObject();
         vetoableChangeSupportSerializedDataVersion = ois.readInt();
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/VetoableChangeSupportTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/VetoableChangeSupportTest.java?rev=399976&r1=399975&r2=399976&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/VetoableChangeSupportTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/VetoableChangeSupportTest.java Thu May  4 22:47:53 2006
@@ -20,15 +20,20 @@
  */
 package org.apache.harmony.tests.java.beans;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
 import java.beans.PropertyChangeEvent;
 import java.beans.VetoableChangeListener;
 import java.beans.VetoableChangeListenerProxy;
 import java.beans.VetoableChangeSupport;
+import java.beans.beancontext.BeanContextChildSupport;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
 
 /**
  * The test checks the class java.beans.VetoableChangeSupport
@@ -74,6 +79,24 @@
         new VetoableChangeSupport("bean1")
                 .addVetoableChangeListener(null, null);
     }
+
+    
+    public void test_readObject() throws Exception {
+        // Regression for HARMONY-421
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        oos.writeObject(new BeanContextChildSupport());
+        oos.flush();
+
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+                baos.toByteArray()));
+        ois.readObject();
+
+        ois.close();
+        oos.close();
+    }
+
 
     /**
      * The test checks the method add() with no property specified