rmannibucau commented on code in PR #34: URL: https://github.com/apache/geronimo-xbean/pull/34#discussion_r1051453129
########## xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java: ########## @@ -41,22 +44,63 @@ public class JarArchive implements Archive, AutoCloseable { private final JarFile jar; private final MJarSupport mjar = new MJarSupport(); - public JarArchive(ClassLoader loader, URL url) { + /* + * Supports only 'file:/...' or 'jar:file:/...!/' URLs + */ + public JarArchive(ClassLoader loader, URL url){ // if (!"jar".equals(url.getProtocol())) throw new IllegalArgumentException("not a jar url: " + url); - try { - this.loader = loader; - this.url = url; - URL u = url; + this.loader = loader; + this.url = url; + File jarFile = null; + String jarPath; + int idx; - String jarPath = url.getFile(); - if (jarPath.contains("!")) { - jarPath = jarPath.substring(0, jarPath.indexOf("!")); - u = new URL(jarPath); + // Wipe out 'jar:' prefix AND '!/{...}' suffix(if any) + if("jar".equalsIgnoreCase(url.getProtocol())){ + + try{ + jarPath = url.getPath(); + url = new URL(jarPath.substring(0, jarPath.lastIndexOf("!/"))); Review Comment: > at the beginning of story single-place change 'indexOf -> lastIndexOf' was fixing the issue this is why I explained you and added also the example that it does *not* fix the issue, it fixes your particular case and breaks others overall both are wrong but indexOf has the advantage to stick on the common case in terms of medium complexity whereas lastIndexOf changes this so I prefer to be conservator on that aspect since it does not help to reverse it on the issue the PR fixes. the thing is that then the file can be wrong so the algorithm is maybe no more correct (using url), this is why I insist we cover all the potential cases to ensure we don't introduce regressions trying to fix one -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@geronimo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org