harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r494780 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/Socket.java test/java/tests/api/java/net/SocketTest.java
Date Wed, 10 Jan 2007 10:49:06 GMT
Author: tellison
Date: Wed Jan 10 02:49:05 2007
New Revision: 494780

URL: http://svn.apache.org/viewvc?view=rev&rev=494780
Log:
Apply patch HARMONY-2944 ([classlib][luni]No Exception was thrown when shutdown the input/output
of a Socket twice)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java?view=diff&rev=494780&r1=494779&r2=494780
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java Wed Jan
10 02:49:05 2007
@@ -696,6 +696,9 @@
      *             if the socket is closed
      */
     public void shutdownInput() throws IOException {
+        if (isInputShutdown()) {
+            throw new SocketException(Msg.getString("K0321")); //$NON-NLS-1$
+        }
         checkClosedAndCreate(false);
         impl.shutdownInput();
         isInputShutdown = true;
@@ -710,6 +713,9 @@
      *             if the socket is closed
      */
     public void shutdownOutput() throws IOException {
+        if (isOutputShutdown()) {
+            throw new SocketException(Msg.getString("KA00f")); //$NON-NLS-1$
+        }
         checkClosedAndCreate(false);
         impl.shutdownOutput();
         isOutputShutdown = true;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java?view=diff&rev=494780&r1=494779&r2=494780
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
Wed Jan 10 02:49:05 2007
@@ -2451,7 +2451,32 @@
             // expected
         }
     }
-    
+
+    /**
+     * @tests Socket#shutdownInput()
+     * @tests Socket#shutdownOutput()
+     */
+    public void test_shutdownInputOutput_twice() throws Exception {
+        // regression test for Harmony-2944
+        Socket s = new Socket("0.0.0.0", 0, false);
+        s.shutdownInput();
+
+        try {
+            s.shutdownInput();
+            fail("should throw SocketException");
+        } catch (SocketException se) {
+            // expected
+        }
+        s.shutdownOutput();
+
+        try {
+            s.shutdownOutput();
+            fail("should throw SocketException");
+        } catch (SocketException se) {
+            // expected
+        }
+    }
+
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.



Mime
View raw message