[ https://issues.apache.org/jira/browse/TWILL-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15428579#comment-15428579 ]
ASF GitHub Bot commented on TWILL-182: -------------------------------------- Github user serranom commented on a diff in the pull request: https://github.com/apache/twill/pull/1#discussion_r75528764 --- Diff: twill-core/src/main/java/org/apache/twill/internal/ApplicationBundler.java --- @@ -215,8 +215,19 @@ public boolean accept(String className, URL classUrl, URL classPathUrl) { private void putEntry(String className, URL classUrl, URL classPathUrl, Set<String> entries, JarOutputStream jarOut) { String classPath = classPathUrl.getFile(); if (classPath.endsWith(".jar")) { + String entryName = classPath.substring(classPath.lastIndexOf('/') + 1); + // need unique name or else we lose classes (TWILL-181) + if (entries.contains(SUBDIR_LIB + entryName)) { + String[] parts = classPath.split("/"); --- End diff -- In this context, we know the classPath urls are all unique because they come from a set. What this logic does is to prepending the entry name with enough elements of this path to make it unique. I presumed there was some desire to keep the entry names short for other reasons. By using the elements from the path we get something guaranteed to be unique while keeping some meaning to the name. > ApplicationBundler will overwrite dependencies with identical names > ------------------------------------------------------------------- > > Key: TWILL-182 > URL: https://issues.apache.org/jira/browse/TWILL-182 > Project: Apache Twill > Issue Type: Bug > Components: core > Affects Versions: 0.7.0-incubating > Reporter: Martin Serrano > Fix For: 0.8.0 > > > If two jars obtained from *different* classpath locations have the same name > but different contents, one will overwrite the other. The dependency code > correctly finds the jars (uses the full path in the HashSet which accumulates > the deps) but when the bundle is created the jars are written to {{/lib}} > under their name. This results in one overwriting the other. > While this is not a likely occurrence, it occurs for us in our development > environment because our published jar names are built up from their project > hierarchy. For example the model project for our sdk is in {{.../sdk/model}} > and will be on the classpath as {{.../sdk/model.jar}} and published as > {{sdk-model.jar}}. > In practice however this could occur with any jar name and would be more > likely over time. > The {{ApplicationBundler}} could detect this and re-write the name with some > part of the path or suffix to ensure the name is unique. -- This message was sent by Atlassian JIRA (v6.3.4#6332)