[ https://issues.apache.org/jira/browse/TWILL-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15424756#comment-15424756 ]
ASF GitHub Bot commented on TWILL-182: -------------------------------------- Github user chtyim commented on a diff in the pull request: https://github.com/apache/twill/pull/1#discussion_r75149838 --- 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 -- I don't quite understand this part of the logic. Is it trying to use some parent directory name as the entryName? Seems like it would lost the original name. Also, if the jar is already at the root directory, then it will be using the original "entryName", which would still result in name conflict? I would suggest simply use package name (derived from `className`) and a random uuid to make it unique if there is conflict. Something like: ```java String entryName = classPath.substring(classPath.lastIndexOf('/') + 1); if (entries.contains(SUBDIR_LIB + entryName)) { entryName = entryName.substring(0, entryName.lastIndexOf('.')) + "-" + className.substring(0, className.lastIndexOf('.')) + "-" + UUID.randomUUID() + ".jar"; } ``` > 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)