Hello,

I also think you can replace the whole code block at 

http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java?annotate=1568683&diff_format=l&pathrev=1568683#l405

with IOUtils.moveFile:

http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#moveFile%28java.io.File,%20java.io.File%29

Gruss
Bernd

Am Sat, 15 Feb 2014 21:30:48 -0000
schrieb s...@apache.org:

> Author: sebb
> Date: Sat Feb 15 21:30:47 2014
> New Revision: 1568683
> 
> URL: http://svn.apache.org/r1568683
> Log:
> FILEUPLOAD-246 FileUpload should use IOUtils.closeQuietly where
> relevant
> 
> Modified:
>     commons/proper/fileupload/trunk/src/changes/changes.xml
>     
> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
> 
> Modified: commons/proper/fileupload/trunk/src/changes/changes.xml
> URL:
> http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/changes/changes.xml?rev=1568683&r1=1568682&r2=1568683&view=diff
> ==============================================================================
> --- commons/proper/fileupload/trunk/src/changes/changes.xml
> (original) +++
> commons/proper/fileupload/trunk/src/changes/changes.xml Sat Feb 15
> 21:30:47 2014 @@ -45,6 +45,7 @@ The <action> type attribute can be
> add,u <body> <release version="1.4" date="TBA" description= "TBA">
> +      <action issue="FILEUPLOAD-246" dev="sebb"
> type="update">FileUpload should use IOUtils.closeQuietly where
> relevant</action> <action issue="FILEUPLOAD-245" dev="sebb"
> type="fix">DiskFileItem.get() may not fully read the data</action>
> <action issue="FILEUPLOAD-243" dev="sebb" type="update" due-to="Ville
> Skyttä">Make some MultipartStream private fields final</action>
> </release>
> 
> Modified:
> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java?rev=1568683&r1=1568682&r2=1568683&view=diff
> ==============================================================================
> ---
> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
> (original) +++
> commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
> Sat Feb 15 21:30:47 2014 @@ -316,13 +316,7 @@ public class
> DiskFileItem } catch (IOException e) { fileData = null; } finally {
> -            if (fis != null) {
> -                try {
> -                    fis.close();
> -                } catch (IOException e) {
> -                    // ignore
> -                }
> -            }
> +            IOUtils.closeQuietly(fis);
>          }
>  
>          return fileData;
> @@ -418,20 +412,8 @@ public class DiskFileItem
>                                  new FileOutputStream(file));
>                          IOUtils.copy(in, out);
>                      } finally {
> -                        if (in != null) {
> -                            try {
> -                                in.close();
> -                            } catch (IOException e) {
> -                                // ignore
> -                            }
> -                        }
> -                        if (out != null) {
> -                            try {
> -                                out.close();
> -                            } catch (IOException e) {
> -                                // ignore
> -                            }
> -                        }
> +                        IOUtils.closeQuietly(in);
> +                        IOUtils.closeQuietly(out);
>                      }
>                  }
>              } else {
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to