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

Interrupted I/O regression

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs
    • generic, sparc
    • solaris_2.6, solaris_7

      It looks like some (ExactVM?) code from 1998 has been merged into 1.3.0.
      In several files the handling of JVM_IO_INTR has been changed to no longer
      throw an InterruptedIOException, presumably because the JVM_* function
      has already thrown it. But the merged version of jvm.c does not
      use CHECK_INTERRUPT() as expected (except in a deadend branch), so
      the exception is never thrown. JDK 1.2.2 and 1.3.1 behave as expected.
      Only 1.3.0 has the problem:

      % cat a.java
      import java.io.*;
      import java.net.*;

      class Interrupter extends Thread {
          Thread target;

          Interrupter(Thread t) {
      target = t;
          }

          public void run() {
      while (target.isAlive()) {
      System.err.println("Sleeping...");
      try {
      Thread.sleep(1 * 1000);
      } catch (Exception e) {
      }
      System.err.println("sending interrupt...");
      target.interrupt();
      }
          }
      }

      public class a {
          public static void main(String argv[]) {
      try {
      new Interrupter(Thread.currentThread()).start();

      InetAddress localhost = InetAddress.getByName("localhost");
      //InetAddress localhost = InetAddress.getLocalHost();

      DatagramSocket s = new DatagramSocket();

      byte[] buf = new byte[1000];
      DatagramPacket recv = new DatagramPacket(buf, buf.length);

      for( int i = 0; i < 3; i++ ) {
      try{
      System.err.println("Waiting for packet...");
      // get their responses!
      s.receive(recv);
      System.out.println("Got packet at iteration " + i +
      " with length " + recv.getLength());
      } catch (Exception e) {
      e.printStackTrace();
      }
      recv.setLength(buf.length);
      }
      } catch (Exception e) {
      System.out.println("Unexpected Exception:" + e);
      }
          }
      }


      % /usr/local/java/jdk1.2.2/solaris/bin/java -version
      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, green threads, sunwjit)

      % /usr/local/java/jdk1.2.2/solaris/bin/java a
      Waiting for packet...
      Sleeping...
      sending interrupt...
      Sleeping...
      java.io.InterruptedIOException: operation interrupted
      at java.net.PlainDatagramSocketImpl.receive(Native Method)
      at java.net.DatagramSocket.receive(DatagramSocket.java, Compiled Code)
      at a.main(a.java, Compiled Code)
      Waiting for packet...
      sending interrupt...
      Sleeping...
      java.io.InterruptedIOException: operation interrupted
      at java.net.PlainDatagramSocketImpl.receive(Native Method)
      at java.net.DatagramSocket.receive(DatagramSocket.java, Compiled Code)
      at a.main(a.java, Compiled Code)
      Waiting for packet...
      sending interrupt...
      Sleeping...
      java.io.InterruptedIOException: operation interrupted
      at java.net.PlainDatagramSocketImpl.receive(Native Method)
      at java.net.DatagramSocket.receive(DatagramSocket.java, Compiled Code)
      at a.main(a.java, Compiled Code)
      sending interrupt...

      % /usr/local/java/jdk1.3/solaris/bin/java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)

      % /usr/local/java/jdk1.3/solaris/bin/java a
      Sleeping...
      Waiting for packet...
      sending interrupt...
      Sleeping...
      Got packet at iteration 0 with length 0
      Waiting for packet...
      sending interrupt...
      Sleeping...
      Got packet at iteration 1 with length 0
      Waiting for packet...
      sending interrupt...
      Sleeping...
      Got packet at iteration 2 with length 0
      sending interrupt...
                                                                                
      dean.long@Eng 2000-10-21

            mmcclosksunw Michael Mccloskey (Inactive)
            dlong Dean Long
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: