close file handle

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163651 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-22 10:07:01 +00:00
parent b63fd801d2
commit 336fa855be
1 changed files with 10 additions and 4 deletions

View File

@ -47,6 +47,7 @@ import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import java.io.File; import java.io.File;
@ -199,9 +200,8 @@ public class DefaultMavenProjectBuilder
{ {
try try
{ {
project.setDistributionManagementArtifactRepository( project.setDistributionManagementArtifactRepository( buildDistributionManagementRepository(
buildDistributionManagementRepository( dm.getRepository() ) );
dm.getRepository() ) );
} }
catch ( Exception e ) catch ( Exception e )
{ {
@ -413,9 +413,11 @@ public class DefaultMavenProjectBuilder
private Model readModel( File file ) private Model readModel( File file )
throws ProjectBuildingException throws ProjectBuildingException
{ {
FileReader reader = null;
try try
{ {
return modelReader.read( new FileReader( file ) ); reader = new FileReader( file );
return modelReader.read( reader );
} }
catch ( FileNotFoundException e ) catch ( FileNotFoundException e )
{ {
@ -426,6 +428,10 @@ public class DefaultMavenProjectBuilder
throw new ProjectBuildingException( throw new ProjectBuildingException(
"Error while reading model from file '" + file.getAbsolutePath() + "'.", e ); "Error while reading model from file '" + file.getAbsolutePath() + "'.", e );
} }
finally
{
IOUtil.close( reader );
}
} }
private Model readModel( URL url ) private Model readModel( URL url )