correctly close jarFile in a finally block

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1358773 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-07-08 16:16:01 +00:00
parent a044b089c9
commit 35c58406a8

View File

@ -752,6 +752,7 @@ public ArtifactContent getArtifactContentText( String groupId, String artifactId
}
finally
{
closeQuietly( jarFile );
IOUtils.closeQuietly( inputStream );
}
}
@ -782,6 +783,21 @@ public ArtifactContent getArtifactContentText( String groupId, String artifactId
return new ArtifactContent();
}
private void closeQuietly( JarFile jarFile )
{
if ( jarFile != null )
{
try
{
jarFile.close();
}
catch ( IOException e )
{
log.warn( "ignore error closing jarFile {}", jarFile.getName() );
}
}
}
//---------------------------
// internals
//---------------------------