You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2014/02/18 00:16:19 UTC
[jira] [Created] (FILEUPLOAD-252) DiskFileItem#write can lose
original IO error
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)