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

Socket doesn't throw IllegalBlockingModeException for read/write stream opers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta2
    • generic
    • generic
    • Verified

      Nonblocking socketchannel doesn't throw IllegalBlockingModeException
      on write or read operations of get{In,Out}putStream().

      Opening a socket channel, setting it nonblocking, and connecting
      to a webserver, it was expected that opening the channel's socket
      input or output stream would cause an IllegalBlockingModeException but the
      operation is permitted and no exceptions are thrown.

      excerpt from the attached test case:
      //.......

      socket = new Socket(WEBHOST,NUM_PORT);
      InetSocketAddress isa = new InetSocketAddress
      (InetAddress.getByName(WEBHOST), NUM_PORT);
      SocketChannel sc = SocketChannel.open();
      sc.configureBlocking(false);
      sc.socket().setSoTimeout(30000);
      boolean x = sc.connect(isa);
      if (!x) {
      System.out.println("Problem connecting to webserver, exit");
      System.exit(1);
      }
      fromServer = new BufferedReader (new InputStreamReader
      (sc.socket().getInputStream() ));
      toServer = new PrintWriter (new OutputStreamWriter
      (sc.socket().getOutputStream() ));

      toServer.print(HTTP_GCMD);
      toServer.print(HTTP_HCMD);
      toServer.flush();
      System.out.println(" ...waiting for webserver to terminate response");
      FileWriter fw = new FileWriter (uniquefilename());

      do {
      s = fromServer.readLine();
      fw.write(s + "\n");

      }
      while (s != null);
      toServer.close();
      fromServer.close();
      fw.close();

      sc.close();
      socket.close();
      System.out.println("Failed.. no exception thrown");


      //..................




      krystyna.polomski@Eng 2001-07-27
      I verified that this was fixed, however, the initial test was incomplete,
      and showed only that the getOutputStream would throw the IllegalBlockingMode Exception. getOutputStream is fixed to throw the exception but getInputStream is not throwing the IllegalBlocking Mode Exception. See a second test attached to prove this.
      /krys


      T I have attached a new test that shows that the IllegalBlockingModeException
      does not get thrown on the get

            mmcclosksunw Michael Mccloskey (Inactive)
            kpolomsksunw Krystyna Polomski (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: