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()
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()
- duplicates
-
JDK-7015589 (spec) BufferedWriter.close leaves stream open if close of underlying Writer fails
-
- Closed
-
- relates to
-
JDK-6335274 FilterOutputStream.close() silently ignores flush() exceptions
-
- Closed
-