Sebb created FILEUPLOAD-252:
-------------------------------
Summary: DiskFileItem#write can lose original IO error
Key: FILEUPLOAD-252
URL: https://issues.apache.org/jira/browse/FILEUPLOAD-252
Project: Commons FileUpload
Issue Type: Bug
Reporter: Sebb
The method DiskFileItem#write has the following code:
{code}
FileOutputStream fout = null;
try {
fout = new FileOutputStream(file);
fout.write(get());
} finally {
if (fout != null) {
fout.close();
}
}
{code}
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:
{code}
FileOutputStream fout = null;
try {
fout = new FileOutputStream(file);
fout.write(get());
fout.close();
} finally {
IOUtils.closeQuietly(fout);
}
{code}
This would ensure that the first error was reported.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)