Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6472249

Socket.shutdownInput() is not discarding data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.5.0_08"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux dhcppc0 2.6.16-2-686 #1 Sat Jul 15 21:59:21 UTC 2006 i686 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      In the Socket.shutdownInput() API doc it reads: "Any data sent to the input stream side of the socket is acknowledged and then silently discarded."
      A small test program to verify this behaviour showed that the data was indeed acknowledged but not discarded.
        See also http://forum.java.sun.com/thread.jspa?threadID=759933

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile and run the test case

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect no blocking at the client side and no TCP ZeroWindow packets coming from the Server side.
      ACTUAL -
      I saw 14 write()/flush() rounds and then write() suddenly blocks. Ethereal then shows TCP ZeroWindow packets coming from the Server side.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import java.net.*;
       
      public class ShutDownInputTest {
          
          private int SERVER_PORT = 65432;
          
          public ShutDownInputTest() {
              Server server = new Server();
              server.start();
              try {
                  Thread.sleep(100);
                  Socket socket = new Socket((String)null, SERVER_PORT);
                  Thread.sleep(100);
                  
                  OutputStream outputStream = socket.getOutputStream();
                  int i = 0;
                  while (true) {
                      System.out.println(i++);
                      outputStream.write(new byte[10000]);
                      System.out.println("flush");
                      outputStream.flush();
                      Thread.sleep(200);
                  }
                  
              } catch (Exception ex) {
                  ex.printStackTrace();
              }
          }
          
          public static void main(String[] args) throws Exception {
              new ShutDownInputTest();
          }
          
          private class Server extends Thread {
              public void run() {
                  try {
                      ServerSocket serverSocket = new ServerSocket(SERVER_PORT);
                      serverSocket.setReuseAddress(true);
                      Socket newSocket = serverSocket.accept();
                      newSocket.shutdownInput();
                  } catch (IOException ex) {
                      ex.printStackTrace();
                  }
              }
          }
      }

      ---------- END SOURCE ----------

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: