harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r527857 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/ObjectOutputStream.java test/java/tests/api/java/io/ObjectOutputStreamTest.java
Date Thu, 12 Apr 2007 09:40:37 GMT
Author: pyang
Date: Thu Apr 12 02:40:36 2007
New Revision: 527857

URL: http://svn.apache.org/viewvc?view=rev&rev=527857
Log:
Apply patch for HARMONY-3610([classlib][luni]java.io.ObjectOutputStream.writeObjectOverride()
throws IOException)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java?view=diff&rev=527857&r1=527856&r2=527857
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
Thu Apr 12 02:40:36 2007
@@ -2059,8 +2059,10 @@
      *             If an IO exception happened when writing the object
      */
     protected void writeObjectOverride(Object object) throws IOException {
-        // Subclasses must override.
-        throw new IOException();
+        if (!subclassOverridingImplementation) {
+            // Subclasses must override.
+            throw new IOException();
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java?view=diff&rev=527857&r1=527856&r2=527857
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
Thu Apr 12 02:40:36 2007
@@ -498,11 +498,11 @@
         protected Object replaceObject(Object obj) throws IOException {
             if (obj instanceof NotSerializable) {
                 return new Long(10);
-            } else if (obj instanceof Integer) {
+            }
+            if (obj instanceof Integer) {
                 return new Long(((Integer) obj).longValue());
-            } else {
-                return obj;
             }
+            return super.replaceObject(obj);            
         }
     }
         
@@ -518,6 +518,21 @@
             return new Long(10);
         }
     }
+    
+    private static class ObjectOutputStreamWriteOverride extends ObjectOutputStream {
+        String test = "test";
+
+        protected ObjectOutputStreamWriteOverride() throws IOException,
+                SecurityException {
+            super();
+        }
+
+        @Override
+        protected void writeObjectOverride(Object object) throws IOException {
+            test = null;
+            super.writeObjectOverride(object);
+        }
+    }
 
 	protected static final String MODE_XLOAD = "xload";
 
@@ -954,6 +969,15 @@
             fail("Expected NotSerializableException");
         } catch (NotSerializableException e) {}
         out.writeObject(new ExternalizableWithReplace());
+    }
+    
+    /**
+     * @tests {@link java.io.ObjectOutputStream#writeObjectOverride(Object)}
+     */
+    public void test_writeObject_WriteOverride() throws Exception {
+        ObjectOutputStreamWriteOverride mockOut = new ObjectOutputStreamWriteOverride();
+        mockOut.writeObject(new Object());
+        assertNull(mockOut.test);
     }
 
     /**



Mime
View raw message