[MPLUGIN-255] Generated HelpMojo doesn't close resource stream

Submitted by: Juan Hernandez
applied with formatting fix

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1578572 13f79535-47bb-0310-9956-ffa450edef68
master
Herve Boutemy 2014-03-17 21:07:49 +00:00
parent abd5f5966a
commit 266d573247
1 changed files with 16 additions and 1 deletions

View File

@ -95,9 +95,10 @@ public class HelpMojo
throws MojoExecutionException
{
getLog().debug( "load plugin-help.xml: " + PLUGIN_HELP_PATH );
InputStream is = getClass().getResourceAsStream( PLUGIN_HELP_PATH );
InputStream is = null;
try
{
is = getClass().getResourceAsStream( PLUGIN_HELP_PATH );
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
return dBuilder.parse( is );
@ -114,6 +115,20 @@ public class HelpMojo
{
throw new MojoExecutionException( e.getMessage(), e );
}
finally
{
if ( is != null )
{
try
{
is.close();
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
}
}
}
/**