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

(spec) FilterOutputStream.close() silently ignores flush() exceptions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      FULL PRODUCT VERSION :

      ADDITIONAL OS VERSION INFORMATION :
      This applies to all OSes

      A DESCRIPTION OF THE PROBLEM :
      FilterOutputStream silently ignores exceptions when doing a flush on close.
      This can hide IO problems such a full disk. The particular case where it got
      me was using a DataOutputStream. I am writing to a temp file and then renaming after close if no exceptions where thrown. However an exception is thrown but ignored when my disk is full. This isn't an issue if some write causes a flush to occur but in the case of a very small file there is no flush called until the close.

      Obvious work around is to call flush yourself. At the very least this needs to be documented.
      The code that causes the issue appears to have been added in responce to the bug 1212301.
      try {
        out.flush();
       } catch (IOException ignored) {
      }
      out.close();

      Despite Bug 6335274 saying this is not a bug and not fixing it. I believe this is still an issue. The author of that bug report may not have gotten the point across well.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The exception should be thrown.
      ACTUAL -
      The exception is ignored.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Call flush() before you call close()

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alanb Alan Bateman
                Reporter:
                ndcosta Nelson Dcosta
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: