harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r423413 - 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 Wed, 19 Jul 2006 09:31:05 GMT
Author: pyang
Date: Wed Jul 19 02:31:03 2006
New Revision: 423413

URL: http://svn.apache.org/viewvc?rev=423413&view=rev
Log:
Fix for HARMONY-913([classlib][nio] o.a.h.nio.DatagramChannelImpl.send(ByteBuffer,SocketAddress)
throws wrong exception)

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=423413&r1=423412&r2=423413&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
Wed Jul 19 02:31:03 2006
@@ -285,10 +285,10 @@
      */
     public int send(ByteBuffer source, SocketAddress address)
             throws IOException {
-        // must open
-        checkOpen();
         // must not null
         checkNotNull(source);
+        // must open
+        checkOpen();
 
         // transfer address
         InetSocketAddress isa = (InetSocketAddress) address;

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=423413&r1=423412&r2=423413&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
Wed Jul 19 02:31:03 2006
@@ -2483,6 +2483,39 @@
         }
     }
     
+    /**
+     * @tests DatagramChannel#send(ByteBuffer, SocketAddress)
+     */
+    public void test_send_LByteBuffer_LSocketAddress_closed() throws IOException{
+        // regression test for Harmony-913
+        channel1.close();
+        ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
+        try {
+            channel1.send(buf, localAddr1);
+            fail("Should throw ClosedChannelException");
+        } catch (ClosedChannelException e) {
+            //pass
+        }
+        try {
+            channel1.send(null,localAddr1);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            //pass
+        }
+        try {
+            channel1.send(buf, null);
+            fail("Should throw ClosedChannelException");
+        } catch (ClosedChannelException e) {
+            //pass
+        }
+        try {
+            channel1.send(null, null);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            //pass
+        }
+    }
+    
     // -------------------------------------------------------------------
     // Mock class for security test.
     // -------------------------------------------------------------------



Mime
View raw message