harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r425269 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
Date Tue, 25 Jul 2006 04:02:06 GMT
Author: pyang
Date: Mon Jul 24 21:02:05 2006
New Revision: 425269

URL: http://svn.apache.org/viewvc?rev=425269&view=rev
Log:
Fix for HARMONY-960 ([classlib][nio]FileChannelImpl.write(ByteBuffer[] buffers, int offset,
int length) checks wrong range)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=425269&r1=425268&r2=425269&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
Mon Jul 24 21:02:05 2006
@@ -131,16 +131,11 @@
         openCheck();
         FileLock resultLock = null;
         {
-            boolean completed = true;
+            boolean completed = false;
             try {
                 begin();
                 resultLock = basicLock(position, size, shared, true);
-            } catch (IOException e) {
-                completed = false;
-                throw e;
-            } catch (RuntimeException e) {
-                completed = false;
-                throw e;
+                completed = true;
             } finally {
                 end(completed);
             }
@@ -256,7 +251,7 @@
         if (!buffer.hasRemaining()){
             return 0;
         }
-        boolean completed = true;
+        boolean completed = false;
         int bytesRead = 0;
 		synchronized (repositioningLock) {
 			if (buffer.isDirect()) {
@@ -269,12 +264,7 @@
                      */
                     bytesRead = (int) fileSystem.readDirect(handle, address,
                             buffer.position(), buffer.remaining());
-                } catch (IOException e) {
-                    completed = false;
-                    throw e;
-                } catch (RuntimeException e) {
-                    completed = false;
-                    throw e;
+                    completed = true;
                 } finally {
                     end(completed && bytesRead >= 0);
                 }
@@ -286,12 +276,7 @@
                      */
                     bytesRead = (int) fileSystem.read(handle, buffer.array(),
                             buffer.arrayOffset(), buffer.remaining());
-                } catch (IOException e) {
-                    completed = false;
-                    throw e;
-                } catch (RuntimeException e) {
-                    completed = false;
-                    throw e;
+                    completed = true;
                 } finally {
                     end(completed && bytesRead >= 0);
                 }
@@ -337,7 +322,7 @@
         }
         long bytesRead = 0;
         {
-            boolean completed = true;
+            boolean completed = false;
             try {
                 begin();
                 synchronized (repositioningLock) {
@@ -345,15 +330,10 @@
                             lengths, length);
 
                 }
+                completed = true;
                 /*
                  * if (bytesRead < EOF) //delt by readv? completed = false;
                  */
-            } catch (IOException e) {
-                completed = false;
-                throw e;
-            } catch (RuntimeException e) {
-                completed = false;
-                throw e;
             } finally {
                 end(completed);
             }
@@ -463,16 +443,12 @@
 
     private long kernelTransfer(long l, FileDescriptor fd, long position,
             long count) throws IOException {
-        boolean completed = true;
+        boolean completed = false;
         try {
             begin();
-            return fileSystem.transfer(l, fd, position, count);
-        } catch (IOException e) {
-            completed = false;
-            throw e;
-        } catch (RuntimeException e) {
-            completed = false;
-            throw e;
+            long ret = fileSystem.transfer(l, fd, position, count);
+            completed = true;
+            return ret;
         } finally {
             end(completed);
         }
@@ -536,7 +512,7 @@
 
     private int writeImpl(ByteBuffer buffer) throws IOException {
 		int bytesWritten;
-        boolean completed = true;
+        boolean completed = false;
 		synchronized (repositioningLock) {
 			if (buffer.isDirect()) {
 				DirectBuffer directBuffer = (DirectBuffer) buffer;
@@ -545,12 +521,7 @@
                     begin();
                     bytesWritten = (int) fileSystem.writeDirect(handle,
                             address, buffer.position(), buffer.remaining());
-                } catch (IOException e) {
-                    completed = false;
-                    throw e;
-                } catch (RuntimeException e) {
-                    completed = false;
-                    throw e;
+                    completed = true;
                 } finally {
                     end(completed);
                 }
@@ -560,12 +531,7 @@
                     bytesWritten = (int) fileSystem.write(handle, buffer
                             .array(), buffer.arrayOffset() + buffer.position(),
                             buffer.remaining());
-                } catch (IOException e) {
-                    completed = false;
-                    throw e;
-                } catch (RuntimeException e) {
-                    completed = false;
-                    throw e;
+                    completed = true;
                 } finally {
                     end(completed);
                 }
@@ -610,25 +576,20 @@
         }
 
         long bytesWritten = 0;
-        boolean completed = true;
+        boolean completed = false;
         synchronized (repositioningLock) {
             try {
                 begin();
                 bytesWritten = fileSystem.writev(handle, handles, offsets,
                         lengths, length);
-            } catch (IOException e) {
-                completed = false;
-                throw e;
-            } catch (RuntimeException e) {
-                completed = false;
-                throw e;
+                completed = true;
             } finally {
                 end(completed);
             }
         }
 
         long bytesRemaining = bytesWritten;
-        for (int i = offset; i < length; i++) {
+        for (int i = offset; i < length + offset; i++) {
             if (bytesRemaining > buffers[i].remaining()) {
                 int pos = buffers[i].limit();
                 buffers[i].position(pos);



Mime
View raw message