You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by ch...@apache.org on 2014/11/07 19:22:29 UTC

incubator-twill git commit: (TWILL-108) Do not fail with exception if same jar is added twice during bundle jar creation

Repository: incubator-twill
Updated Branches:
  refs/heads/master 301ce9698 -> 925b85fc1


(TWILL-108) Do not fail with exception if same jar is added twice during bundle jar creation

Signed-off-by: Terence Yim <ch...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-twill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-twill/commit/925b85fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-twill/tree/925b85fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-twill/diff/925b85fc

Branch: refs/heads/master
Commit: 925b85fc1756e539726d6b1b65ffcef36e601c9c
Parents: 301ce96
Author: Mike Walch <mw...@gmail.com>
Authored: Wed Nov 5 11:13:49 2014 -0500
Committer: Terence Yim <ch...@apache.org>
Committed: Fri Nov 7 10:20:42 2014 -0800

----------------------------------------------------------------------
 .../apache/twill/internal/ApplicationBundler.java   | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/925b85fc/twill-core/src/main/java/org/apache/twill/internal/ApplicationBundler.java
----------------------------------------------------------------------
diff --git a/twill-core/src/main/java/org/apache/twill/internal/ApplicationBundler.java b/twill-core/src/main/java/org/apache/twill/internal/ApplicationBundler.java
index dcc4dbd..3f2d073 100644
--- a/twill-core/src/main/java/org/apache/twill/internal/ApplicationBundler.java
+++ b/twill-core/src/main/java/org/apache/twill/internal/ApplicationBundler.java
@@ -343,13 +343,15 @@ public final class ApplicationBundler {
     String prefix = path.endsWith(".jar") ? SUBDIR_LIB : SUBDIR_RESOURCES;
     path = prefix + path.substring(path.lastIndexOf('/') + 1);
 
-    saveDirEntry(prefix, entries, jarOut);
-    jarOut.putNextEntry(new JarEntry(path));
-    InputStream is = url.openStream();
-    try {
-      ByteStreams.copy(is, jarOut);
-    } finally {
-      is.close();
+    if (entries.add(path)) {
+      saveDirEntry(prefix, entries, jarOut);
+      jarOut.putNextEntry(new JarEntry(path));
+      InputStream is = url.openStream();
+      try {
+        ByteStreams.copy(is, jarOut);
+      } finally {
+        is.close();
+      }
     }
   }