You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/05/13 01:15:54 UTC

svn commit: r1337729 - in /maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator: PluginDescriptorGenerator.java PluginHelpGenerator.java

Author: olamy
Date: Sat May 12 23:15:53 2012
New Revision: 1337729

URL: http://svn.apache.org/viewvc?rev=1337729&view=rev
Log:
take care to close stream in finally block

Modified:
    maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
    maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java

Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java?rev=1337729&r1=1337728&r2=1337729&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Sat May 12 23:15:53 2012
@@ -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 );

Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=1337729&r1=1337728&r2=1337729&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java Sat May 12 23:15:53 2012
@@ -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";