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

PrintWriter handling of InterruptedIOException should be removed

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 19
    • core-libs
    • None
    • behavioral
    • minimal
    • Minimal risk as verbiage is being changed to match existing behavior.
    • Java API
    • SE

      Summary

      Remove references to vestigial java.io.InterruptedIOException.

      Problem

      The specification of the method java.io.PrintStream.checkError() includes references to InterruptedIOException which is vestige of legacy and Solaris-specific interruptible I/O

      Solution

      Remove references to InterruptedIOException. In passing also make the verbiage of the checkError(), clearError(), and setError() methods consistent between PrintStream and java.io.PrintWriter.

      Specification

      --- a/src/java.base/share/classes/java/io/PrintStream.java
      +++ b/src/java.base/share/classes/java/io/PrintStream.java
      @@ -464,22 +464,11 @@ public class PrintStream extends FilterOutputStream
           }
      
           /**
      -     * Flushes the stream and checks its error state. The internal error state
      -     * is set to {@code true} when the underlying output stream throws an
      -     * {@code IOException} other than {@code InterruptedIOException},
      -     * and when the {@code setError} method is invoked.  If an operation
      -     * on the underlying output stream throws an
      -     * {@code InterruptedIOException}, then the {@code PrintStream}
      -     * converts the exception back into an interrupt by doing:
      -     * <pre>{@code
      -     *     Thread.currentThread().interrupt();
      -     * }</pre>
      -     * or the equivalent.
      +     * Flushes the stream if it's not closed and checks its error state.
            *
            * @return {@code true} if and only if this stream has encountered an
      -     *         {@code IOException} other than
      -     *         {@code InterruptedIOException}, or the
      -     *         {@code setError} method has been invoked
      +     *         {@code IOException}, or the {@code setError} method has been
      +     *         invoked
            */
           public boolean checkError() {
               if (out != null)
      @@ -504,7 +493,7 @@ public class PrintStream extends FilterOutputStream
           }
      
           /**
      -     * Clears the internal error state of this stream.
      +     * Clears the error state of this stream.
            *
            * <p> This method will cause subsequent invocations of {@link
            * #checkError()} to return {@code false} until another write
      --- a/src/java.base/share/classes/java/io/PrintWriter.java
      +++ b/src/java.base/share/classes/java/io/PrintWriter.java
      @@ -428,9 +428,9 @@ public class PrintWriter extends Writer {
           /**
            * Flushes the stream if it's not closed and checks its error state.
            *
      -     * @return {@code true} if the print stream has encountered an error,
      -     *          either on the underlying output stream or during a format
      -     *          conversion.
      +     * @return {@code true} if and only if this stream has encountered an
      +     *         {@code IOException}, or the {@code setError} method has been
      +     *         invoked
            */
           public boolean checkError() {
               if (out != null) {
      @@ -445,7 +445,7 @@ public class PrintWriter extends Writer {
           }
      
           /**
      -     * Indicates that an error has occurred.
      +     * Sets the error state of the stream to {@code true}.
            *
            * <p> This method will cause subsequent invocations of {@link
            * #checkError()} to return {@code true} until {@link

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: