harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r393019 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/org/apache/harmony/luni/platform/ test/java/org/apache/harmony/tests/java/io/
Date Mon, 10 Apr 2006 18:31:11 GMT
Author: gharley
Date: Mon Apr 10 11:31:09 2006
New Revision: 393019

URL: http://svn.apache.org/viewcvs?rev=393019&view=rev
Log:
HARMONY 285 : methods in FileOutputStream and FileInputStream crash VM if use null as parameter
for byte array

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileInputStreamTest.java
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileOutputStreamTest.java
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java?rev=393019&r1=393018&r2=393019&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
Mon Apr 10 11:31:09 2006
@@ -137,6 +137,9 @@
 
 	public long read(long fileDescriptor, byte[] bytes, int offset, int length)
 			throws IOException {
+		if (bytes == null) {
+			throw new NullPointerException();
+		}
 		long bytesRead = readImpl(fileDescriptor, bytes, offset, length);
 		if (bytesRead < -1) {
 			throw new IOException();
@@ -149,6 +152,9 @@
 
 	public long write(long fileDescriptor, byte[] bytes, int offset, int length)
 			throws IOException {
+		if (bytes == null) {
+			throw new NullPointerException();
+		}
 		long bytesWritten = writeImpl(fileDescriptor, bytes, offset, length);
 		if (bytesWritten < 0) {
 			throw new IOException();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java?rev=393019&r1=393018&r2=393019&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
Mon Apr 10 11:31:09 2006
@@ -32,6 +32,8 @@
 		suite.addTestSuite(FilePermissionTest.class);
 		suite.addTestSuite(BufferedInputStreamTest.class);
 		suite.addTestSuite(FileTest.class);
+        suite.addTestSuite(FileInputStreamTest.class);
+        suite.addTestSuite(FileOutputStreamTest.class);
         suite.addTestSuite(InputStreamReaderTest.class);
 		suite.addTestSuite(BufferedReaderTest.class);
 		suite.addTestSuite(PushBackInputStreamTest.class);

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileInputStreamTest.java?rev=393019&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileInputStreamTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileInputStreamTest.java
Mon Apr 10 11:31:09 2006
@@ -0,0 +1,40 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.io;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import junit.framework.TestCase;
+
+public class FileInputStreamTest extends TestCase {
+
+    /**
+     * @tests java.io.FileInputStream#read(byte[], int, int)
+     */
+    public void test_read$BII() throws Exception {
+        // Regression test for HARMONY-285
+        try {
+            File file = new File("FileInputStream.tmp");
+            file.createNewFile();
+            file.deleteOnExit();
+            FileInputStream in = new FileInputStream(file);
+            in.read(null, 0, 0);
+        } catch (NullPointerException e) {
+        }
+    }
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileOutputStreamTest.java?rev=393019&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileOutputStreamTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileOutputStreamTest.java
Mon Apr 10 11:31:09 2006
@@ -0,0 +1,39 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.io;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import junit.framework.TestCase;
+
+public class FileOutputStreamTest extends TestCase {
+
+    /**
+     * @tests java.io.FileOutputStream#write(byte[], int, int)
+     */
+    public void test_write$BII() throws Exception {
+        // Regression test for HARMONY-285
+        try {
+            File file = new File("FileOutputStream.tmp");
+            file.deleteOnExit();
+            FileOutputStream out = new FileOutputStream(file);
+            out.write(null, 0, 0);
+        } catch (NullPointerException e) {
+        }
+    }
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileOutputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message