You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/10/12 18:20:50 UTC

svn commit: r463302 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/io/RandomAccessFile.java org/apache/harmony/luni/platform/OSFileSystem.java

Author: pyang
Date: Thu Oct 12 09:20:48 2006
New Revision: 463302

URL: http://svn.apache.org/viewvc?view=rev&rev=463302
Log:
Roll back the patch for HARMONY-1790([classlib][io] remove duplicated exception check in RandomAccessFile#write(byte, int, int)), which caused RandomFileTest fail on Linux

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java?view=diff&rev=463302&r1=463301&r2=463302
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java Thu Oct 12 09:20:48 2006
@@ -739,9 +739,16 @@
      * @see #read(byte[], int, int)
      */
     public void write(byte[] buffer, int offset, int count) throws IOException {
-    	if (count > buffer.length - offset || count < 0 || offset < 0) {
+    	if (null == buffer) {
+    		throw new NullPointerException();
+    	}
+        if (count < 0 || offset < 0 || count > buffer.length - offset) {
             throw new IndexOutOfBoundsException();
         }
+        if (0 == count){
+        	return;
+        }
+        openCheck();
         synchronized (repositionLock) {
             fileSystem.write(fd.descriptor, buffer, offset, count);
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java?view=diff&rev=463302&r1=463301&r2=463302
==============================================================================
--- 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 Thu Oct 12 09:20:48 2006
@@ -154,6 +154,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();