harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r421870 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/Socket.java main/java/org/apache/harmony/luni/util/ExternalMessages.properties test/java/tests/api/java/net/SocketTest.java
Date Fri, 14 Jul 2006 11:23:48 GMT
Author: gharley
Date: Fri Jul 14 04:23:47 2006
New Revision: 421870

URL: http://svn.apache.org/viewvc?rev=421870&view=rev
Log:
HARMONY 873 : [luni] java.net.Socket.getOutputStream should throw SocketException if output
has been shutdown

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java?rev=421870&r1=421869&r2=421870&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
Fri Jul 14 04:23:47 2006
@@ -402,6 +402,9 @@
 	 */
 	public OutputStream getOutputStream() throws IOException {
 		checkClosedAndCreate(false);
+        if (isOutputShutdown()) {
+            throw new SocketException(Msg.getString("KA00f"));
+        }
 		return impl.getOutputStream();
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=421870&r1=421869&r2=421870&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
Fri Jul 14 04:23:47 2006
@@ -300,4 +300,4 @@
 KA00c=Readable is null
 KA00d=ReadableByteChannel is null
 KA00e=Radix {0} is less than Character.MIN_RADIX or greater than Character.MAX_RADIX
-
+KA00f=Socket output is shutdown

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java?rev=421870&r1=421869&r2=421870&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
Fri Jul 14 04:23:47 2006
@@ -2397,6 +2397,23 @@
             // expected
         }
     }
+    
+    /**
+     * @tests Socket#getOutputStream()
+     */
+    public void test_getOutputStream_shutdownOutput() throws Exception {
+        // regression test for Harmony-873
+        ServerSocket ss = new ServerSocket(0);
+        Socket s = new Socket("127.0.0.1", ss.getLocalPort());
+        ss.accept();
+        s.shutdownOutput();
+        try {
+            s.getOutputStream();
+            fail("should throw SocketException");
+        } catch (SocketException e) {
+            // expected
+        }
+    }
 
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method



Mime
View raw message