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

java.net.Socket.close does not throw IOException on second close

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P5
    • Resolution: Won't Fix
    • Affects Version/s: 1.1.4
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: yyC67448 Date: 09/30/97



      The java.net.Socket.close() does not throw IOException when
      closing already closed socket.

      Here is the test demonstrating the bug:

      -------------------------------- Test.java -----------------------------
      import java.io.*;
      import java.net.*;


      class test
      {

        public static void main(String args[])
        {
          InetAddress sin = null;
          Socket soc = null;
          int value = 0;


          /*
           * Try to get localhost address
           */
          try {
            sin = InetAddress.getLocalHost();
          } catch(Exception e)
          {
            System.out.println("Can not get localhost Address:" + e);
            System.exit(-1);
          }


          /*
           * Hope Telnet service enabled on localhost.
           */
          try {
            soc = new Socket(sin, 23, true);
          } catch(Exception e)
          {
            System.out.println("Can not create socket:" + e);
            System.exit(-1);
          }

          /*
           * Try to close socket
           */
          try {
            soc.close();
          } catch(Exception e)
          {
      System.out.println("Can not close socket first time:" + e);
      System.exit(-1);
          }

          /*
           * Try to close once more...
           */
          try {
            soc.close();
          } catch(IOException e)
          {
            System.out.println("OKAY");
            System.exit(0);
          }
          catch(Exception e)
          {
            System.out.println("Unexpected exception :" + e);
            System.exit(-1);
          }

          System.out.println("No exceptions.");
          
        }
      }


      ---------------------- Output from the test -----------------
      No exceptions.
      -----------------------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: