]> source.dussan.org Git - archiva.git/commitdiff
correctly close streams
authorOlivier Lamy <olamy@apache.org>
Thu, 19 Dec 2013 00:51:34 +0000 (00:51 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 19 Dec 2013 00:51:34 +0000 (00:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1552191 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java

index eefe81a7bad0b61565a63d7b34ac23ac813028d7..59c352b25ee52fced7c0caa629ceeacd758f43dc 100644 (file)
@@ -575,17 +575,19 @@ public class DefaultFileUploadService
     private void copyFile( File sourceFile, File targetPath, String targetFilename, boolean fixChecksums )
         throws IOException
     {
-        FileOutputStream out = new FileOutputStream( new File( targetPath, targetFilename ) );
-        FileInputStream input = new FileInputStream( sourceFile );
+        FileOutputStream out = null;
+        FileInputStream input = null;
 
         try
         {
+            out = new FileOutputStream( new File( targetPath, targetFilename ) );
+            input = new FileInputStream( sourceFile );
             IOUtils.copy( input, out );
         }
         finally
         {
-            out.close();
-            input.close();
+            IOUtils.closeQuietly( out );
+            IOUtils.closeQuietly( input );
         }
 
         if ( fixChecksums )