Index: src/main/java/java/net/Socket.java =================================================================== --- src/main/java/java/net/Socket.java (revision 494388) +++ src/main/java/java/net/Socket.java (working copy) @@ -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; Index: src/test/java/tests/api/java/net/SocketTest.java =================================================================== --- src/test/java/tests/api/java/net/SocketTest.java (revision 494388) +++ src/test/java/tests/api/java/net/SocketTest.java (working copy) @@ -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.