harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r423918 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src: main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java test/java/common/org/apache/harmony/tests/java/nio/channels/DatagramChannelTest.java
Date Thu, 20 Jul 2006 12:48:26 GMT
Author: pyang
Date: Thu Jul 20 05:48:26 2006
New Revision: 423918

URL: http://svn.apache.org/viewvc?rev=423918&view=rev
Log:
Fix for HARMONY-932 ([classlib][nio]java.nio.channels.DatagramChannel.read(ByteBuffer[] ,
int, Integer.MAX_VALUE) throws NotYetConnectedException while RI throws IndexOutOfBoundsException)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/DatagramChannelTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java?rev=423918&r1=423917&r2=423918&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java
Thu Jul 20 05:48:26 2006
@@ -380,7 +380,7 @@
      */
     public long read(ByteBuffer[] targets, int offset, int length)
             throws IOException {
-        if (length < 0 || offset < 0 || length + offset > targets.length) {
+        if (length < 0 || offset < 0 || (long)length + (long)offset > targets.length)
{
             throw new IndexOutOfBoundsException();
         }        
         // status must be open and connected
@@ -470,7 +470,7 @@
      */
     public long write(ByteBuffer[] sources, int offset, int length)
             throws IOException {
-        if (length < 0 || offset < 0 || length + offset > sources.length) {
+        if (length < 0 || offset < 0 || (long)length + (long)offset > sources.length)
{
             throw new IndexOutOfBoundsException();
         }
         // status must be open and connected

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/DatagramChannelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/DatagramChannelTest.java?rev=423918&r1=423917&r2=423918&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/DatagramChannelTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/DatagramChannelTest.java
Thu Jul 20 05:48:26 2006
@@ -1863,6 +1863,25 @@
         assertEquals(0, this.channel1.read(readBuf, 0, 1));
         assertEquals(0, this.channel1.read(readBuf, 0, 2));
         datagramSocket1.close();
+        //regression test for HARMONY-932
+        try {
+        	DatagramChannel.open().read(new ByteBuffer[] {}, 2, Integer.MAX_VALUE);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // correct
+        }
+        try {
+        	DatagramChannel.open().write(new ByteBuffer[] {}, 2, Integer.MAX_VALUE);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // correct
+        }
+        try {
+        	DatagramChannel.open().write((ByteBuffer[])null, -1, 2);
+            fail("should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // correct
+        }
     }
 
     public void testReadByteBufferArrayIntInt_BufNull() throws IOException {



Mime
View raw message