Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The method DiskFileItem#write has the following code:
FileOutputStream fout = null; try { fout = new FileOutputStream(file); fout.write(get()); } finally { if (fout != null) { fout.close(); } }
If the write fails and then the close fails, the write failure will be masked by the close error. It might be better to write the code as:
FileOutputStream fout = null; try { fout = new FileOutputStream(file); fout.write(get()); fout.close(); } finally { IOUtils.closeQuietly(fout); }
This would ensure that the first error was reported.