You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2015/07/09 11:48:22 UTC

karaf git commit: [KARAF-3811] JarFile not closed correctly when building the assembly

Repository: karaf
Updated Branches:
  refs/heads/master 497c313b1 -> 8130fd7d1


[KARAF-3811] JarFile not closed correctly when building the assembly

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8130fd7d
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8130fd7d
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8130fd7d

Branch: refs/heads/master
Commit: 8130fd7d19355625c3b49d0d82e4a0cd323c2d48
Parents: 497c313
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jul 9 11:48:07 2015 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jul 9 11:48:07 2015 +0200

----------------------------------------------------------------------
 .../karaf/profile/assembly/AssemblyDeployCallback.java      | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/8130fd7d/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java b/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
index 4ef295c..3edb777 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
@@ -209,10 +209,11 @@ public class AssemblyDeployCallback implements Deployer.DeployCallback {
             Files.copy(is, bundleSystemFile, StandardCopyOption.REPLACE_EXISTING);
 
             Hashtable<String, String> headers = new Hashtable<>();
-            JarFile jar = new JarFile(bundleSystemFile.toFile());
-            Attributes attributes = jar.getManifest().getMainAttributes();
-            for (Map.Entry attr : attributes.entrySet()) {
-                headers.put(attr.getKey().toString(), attr.getValue().toString());
+            try (JarFile jar = new JarFile(bundleSystemFile.toFile())) {
+                Attributes attributes = jar.getManifest().getMainAttributes();
+                for (Map.Entry attr : attributes.entrySet()) {
+                    headers.put(attr.getKey().toString(), attr.getValue().toString());
+                }
             }
             BundleRevision revision = new FakeBundleRevision(headers, uri, nextBundleId.incrementAndGet());
             Bundle bundle = revision.getBundle();