commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (FILEUPLOAD-252) DiskFileItem#write can lose original IO error
Date Tue, 11 Nov 2014 20:45:34 GMT

     [ https://issues.apache.org/jira/browse/FILEUPLOAD-252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thomas Neidhart resolved FILEUPLOAD-252.
----------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.4

Fixed in r1638380.

> 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
>             Fix For: 1.4
>
>
> 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.3.4#6332)

Mime
View raw message