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

PrintStream.flush() clears thread interrupt flag (sol)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0u9
    • core-libs
    • sparc
    • solaris_2.5.1

      Problem :

      System.out.flush() sets the thread's interrupted status flag from true to false on Solaris.
      Other io methods like println() do not change threads interrupted status.

      Test Case:

      public class InterruptTest extends Thread {

          public InterruptTest() {
          }

          public void run() {
              System.out.println("The interrupt flag is initially " +
      this.isInterrupted() );
              System.out.println("Setting the interrupt flag to true.");
              this.interrupt();
              System.out.println("The interrupt flag is now " +
      this.isInterrupted() );
              System.out.flush();
              if (this.isInterrupted() == false) {
                  System.out.println("ERROR: After calling flush(), the
      interrupt " +
                                     "flag is now false, but is should be true.");
              }
              else {
                  System.out.println("After calling flush(), the interrupt
      flag " +
                                     " is still true, which is the correct
      result.");
              }
          }

          public static void main(String[] args) {
              InterruptTest test = new InterruptTest();
              test.start();

              try {
                  test.join();
              }
              catch (InterruptedException e) {
                  System.err.println("ERROR: InterruptTest interrupted during
      join");
              }
          }
      }


      O/P on Windows :
      The interrupt flag is initially false
      Setting the interrupt flag to true.
      The interrupt flag is now true
      After calling flush(), the interrupt flag is still true, which is the correct result.

      O/P on Solaris :
      The interrupt flag is initially false
      Setting the interrupt flag to true.
      The interrupt flag is now true
      ERROR: After calling flush(), the interrupt flag is now false, but is should be true.

      Is this inconsistent behaviour intended?

            iris Iris Clark
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: