harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r432348 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/DataOutputStream.java test/java/tests/api/java/io/DataOutputStreamTest.java
Date Thu, 17 Aug 2006 19:14:07 GMT
Author: tellison
Date: Thu Aug 17 12:14:06 2006
New Revision: 432348

URL: http://svn.apache.org/viewvc?rev=432348&view=rev
Log:
Apply patch HARMONY-1100 ([classlib][io] compatibility: Harmony method DataOutputStream(null).writeBytes("")
throws NPE while RI does not)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataOutputStream.java?rev=432348&r1=432347&r2=432348&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataOutputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataOutputStream.java
Thu Aug 17 12:14:06 2006
@@ -157,6 +157,9 @@
 	 * @see DataInput#readFully(byte[],int,int)
 	 */
 	public final void writeBytes(String str) throws IOException {
+		if (str.length() == 0) {
+			return;
+		}
 		byte bytes[] = new byte[str.length()];
 		for (int index = 0; index < str.length(); index++)
 			bytes[index] = (byte) str.charAt(index);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java?rev=432348&r1=432347&r2=432348&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java
Thu Aug 17 12:14:06 2006
@@ -151,7 +151,7 @@
 	/**
 	 * @tests java.io.DataOutputStream#writeBytes(java.lang.String)
 	 */
-	public void test_writeBytesLjava_lang_String() {
+	public void test_writeBytesLjava_lang_String() throws IOException {
 		// Test for method void
 		// java.io.DataOutputStream.writeBytes(java.lang.String)
 		try {
@@ -166,6 +166,8 @@
 		} catch (IOException e) {
 			fail("Exception during writeBytes test : " + e.getMessage());
 		}
+		// regression test for HARMONY-1101
+		new DataOutputStream(null).writeBytes("");
 	}
 
 	/**



Mime
View raw message