FELIX-661: remember to close JarFiles (also raised under MSHARED-53)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@683332 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
index 9e0f24e..60d6ee1 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
@@ -82,9 +82,10 @@
         {
             Analyzer analyzer = new Analyzer();
 
+            JarFile jar = null;
             try
             {
-                JarFile jar = new JarFile( artifact.getFile(), false );
+                jar = new JarFile( artifact.getFile(), false );
 
                 if ( jar.getManifest() != null )
                 {
@@ -104,6 +105,19 @@
                 throw new ManifestReadingException( "Error reading manifest in jar "
                     + artifact.getFile().getAbsolutePath(), e );
             }
+            finally
+            {
+                if ( jar != null )
+                {
+                    try
+                    {
+                        jar.close();
+                    }
+                    catch ( IOException e )
+                    {
+                    }
+                }
+            }
         }
 
         int i = artifact.getGroupId().lastIndexOf( '.' );
@@ -156,6 +170,7 @@
                     }
                 }
             }
+            jar.close();
 
             /* find the top package */
             String[] groupIdSections = null;