maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1200898 - /maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
Date Fri, 11 Nov 2011 14:26:57 GMT
Author: hboutemy
Date: Fri Nov 11 14:26:56 2011
New Revision: 1200898

URL: http://svn.apache.org/viewvc?rev=1200898&view=rev
Log:
close stream

Modified:
    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/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=1200898&r1=1200897&r2=1200898&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
Fri Nov 11 14:26:56 2011
@@ -247,35 +247,33 @@ public class PluginHelpGenerator
         {
             MojoDescriptor descriptor = it.next();
 
+            String name = "";
+            int next = 1;
+
             String impl = descriptor.getImplementation();
             if ( impl.lastIndexOf( '.' ) != -1 )
             {
-                String name = impl.substring( 0, impl.lastIndexOf( '.' ) );
-                if ( packageNames.get( name ) != null )
-                {
-                    int next = ( (Integer) packageNames.get( name ) ).intValue() + 1;
-                    packageNames.put( name, new Integer( next ) );
-                }
-                else
+                name = impl.substring( 0, impl.lastIndexOf( '.' ) );
+                Integer count = packageNames.get( name );
+
+                if ( count != null )
                 {
-                    packageNames.put( name, new Integer( 1 ) );
+                    next = count.intValue() + 1;
                 }
             }
-            else
-            {
-                packageNames.put( "", new Integer( 1 ) );
-            }
+
+            packageNames.put( name, next );
         }
 
         String packageName = "";
         int max = 0;
-        for ( String key : packageNames.keySet() )
+        for ( Map.Entry<String, Integer> entry : packageNames.entrySet() )
         {
-            int value = ( (Integer) packageNames.get( key ) ).intValue();
+            int value = entry.getValue().intValue();
             if ( value > max )
             {
                 max = value;
-                packageName = key;
+                packageName = entry.getKey();
             }
         }
 
@@ -379,6 +377,10 @@ public class PluginHelpGenerator
             {
                 // nope
             }
+            finally
+            {
+                IOUtil.close( resourceAsStream );
+            }
         }
 
         writer.write( "/**" + LS );
@@ -512,10 +514,8 @@ public class PluginHelpGenerator
 
         writer.write( LS );
 
-        for ( Iterator<MojoDescriptor> it = mojoDescriptors.iterator(); it.hasNext();
)
+        for ( MojoDescriptor descriptor : mojoDescriptors )
         {
-            MojoDescriptor descriptor = it.next();
-
             writeGoal( writer, descriptor );
         }
 



Mime
View raw message