correctly close streams

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1552191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-12-19 00:51:34 +00:00
parent 14736745e4
commit fae670bbc1
1 changed files with 6 additions and 4 deletions

View File

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