take care to close stream in finally block

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1337729 13f79535-47bb-0310-9956-ffa450edef68
master
Olivier Lamy 2012-05-12 23:15:53 +00:00
parent 218d09253e
commit b606a755c8
2 changed files with 13 additions and 5 deletions

View File

@ -74,14 +74,20 @@ public class PluginDescriptorGenerator
if ( tmpPropertiesFile.exists() )
{
Properties properties = new Properties();
FileInputStream fis = null;
try
{
properties.load( new FileInputStream( tmpPropertiesFile ) );
fis = new FileInputStream( tmpPropertiesFile );
properties.load( fis );
}
catch ( IOException e )
{
throw new GeneratorException( e.getMessage(), e );
}
finally
{
IOUtil.close( fis );
}
String helpPackageName = properties.getProperty( "helpPackageName" );
// if helpPackageName property is empty we have to rewrite the class with a better package name than empty
if ( StringUtils.isEmpty( helpPackageName ) )
@ -171,8 +177,7 @@ public class PluginDescriptorGenerator
if ( pluginDescriptor.getMojos() != null )
{
@SuppressWarnings( "unchecked" )
List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
@SuppressWarnings( "unchecked" ) List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
for ( MojoDescriptor descriptor : descriptors )
{
processMojoDescriptor( descriptor, w, cleanDescription );

View File

@ -133,14 +133,17 @@ public class PluginHelpGenerator
tmpPropertiesFile.getParentFile().mkdirs();
}
}
FileOutputStream fos = null;
try
{
properties.store( new FileOutputStream( tmpPropertiesFile ), "maven plugin help generation informations" );
fos = new FileOutputStream( tmpPropertiesFile );
properties.store( fos, "maven plugin help generation informations" );
}
catch ( IOException e )
{
throw new GeneratorException( e.getMessage(), e );
} finally {
IOUtil.close( fos );
}
String sourcePath = helpImplementation.replace( '.', File.separatorChar ) + ".java";