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-ffa450edef68master
parent
218d09253e
commit
b606a755c8
|
|
@ -74,14 +74,20 @@ public class PluginDescriptorGenerator
|
||||||
if ( tmpPropertiesFile.exists() )
|
if ( tmpPropertiesFile.exists() )
|
||||||
{
|
{
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
FileInputStream fis = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
properties.load( new FileInputStream( tmpPropertiesFile ) );
|
fis = new FileInputStream( tmpPropertiesFile );
|
||||||
|
properties.load( fis );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new GeneratorException( e.getMessage(), e );
|
throw new GeneratorException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( fis );
|
||||||
|
}
|
||||||
String helpPackageName = properties.getProperty( "helpPackageName" );
|
String helpPackageName = properties.getProperty( "helpPackageName" );
|
||||||
// if helpPackageName property is empty we have to rewrite the class with a better package name than empty
|
// if helpPackageName property is empty we have to rewrite the class with a better package name than empty
|
||||||
if ( StringUtils.isEmpty( helpPackageName ) )
|
if ( StringUtils.isEmpty( helpPackageName ) )
|
||||||
|
|
@ -171,8 +177,7 @@ public class PluginDescriptorGenerator
|
||||||
|
|
||||||
if ( pluginDescriptor.getMojos() != null )
|
if ( pluginDescriptor.getMojos() != null )
|
||||||
{
|
{
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" ) List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
|
||||||
List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
|
|
||||||
for ( MojoDescriptor descriptor : descriptors )
|
for ( MojoDescriptor descriptor : descriptors )
|
||||||
{
|
{
|
||||||
processMojoDescriptor( descriptor, w, cleanDescription );
|
processMojoDescriptor( descriptor, w, cleanDescription );
|
||||||
|
|
|
||||||
|
|
@ -133,14 +133,17 @@ public class PluginHelpGenerator
|
||||||
tmpPropertiesFile.getParentFile().mkdirs();
|
tmpPropertiesFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FileOutputStream fos = null;
|
||||||
try
|
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 )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new GeneratorException( e.getMessage(), e );
|
throw new GeneratorException( e.getMessage(), e );
|
||||||
|
} finally {
|
||||||
|
IOUtil.close( fos );
|
||||||
}
|
}
|
||||||
|
|
||||||
String sourcePath = helpImplementation.replace( '.', File.separatorChar ) + ".java";
|
String sourcePath = helpImplementation.replace( '.', File.separatorChar ) + ".java";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue