harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r409192 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/ObjectOutputStream.java test/java/tests/api/java/io/ObjectOutputStreamTest.java
Date Wed, 24 May 2006 15:33:47 GMT
Author: mloenko
Date: Wed May 24 08:33:46 2006
New Revision: 409192

URL: http://svn.apache.org/viewvc?rev=409192&view=rev
Log:
fixes and regression test for HARMONY-188
ObjectOutputStream.useProtocolVersion(version) should check a parameter value

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java?rev=409192&r1=409191&r2=409192&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
Wed May 24 08:33:46 2006
@@ -794,8 +794,13 @@
 	 *             If an IO error occurs
 	 */
 	public void useProtocolVersion(int version) throws IOException {
-		protocolVersion = version;
-	}
+        if (version != ObjectStreamConstants.PROTOCOL_VERSION_1
+                && version != ObjectStreamConstants.PROTOCOL_VERSION_2) {
+            throw new IllegalArgumentException(org.apache.harmony.luni.util.Msg
+                    .getString("K00b3", version)); //$NON-NLS-1$
+        }
+        protocolVersion = version;
+    }
 
 	/**
 	 * Writes the entire contents of the byte array <code>buffer</code> to

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java?rev=409192&r1=409191&r2=409192&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java
Wed May 24 08:33:46 2006
@@ -1085,4 +1085,23 @@
         dump(o);
         return reload();
     }
+
+    /**
+     * @tests java.io.ObjectOutputStream#useProtocolVersion(int)
+     */
+    public void test_useProtocolVersionI_2() throws Exception {
+        ObjectOutputStream oos = new ObjectOutputStream(
+                new ByteArrayOutputStream());
+
+        oos.useProtocolVersion(ObjectOutputStream.PROTOCOL_VERSION_1);
+        oos.useProtocolVersion(ObjectOutputStream.PROTOCOL_VERSION_2);
+        try {
+            oos.useProtocolVersion(3);
+            fail("Protocol 3 should not be accepted");
+        } catch (IllegalArgumentException e) {
+            // expected
+        } finally {
+            oos.close();
+        }
+    }
 }



Mime
View raw message