harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject 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
Date Fri, 05 May 2006 05:47:53 GMT
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



Mime
View raw message