diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-02 22:32:30 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-02 22:32:30 +0200 |
commit | 787529a7ec4a567a31b375f76954ea31714a7c86 (patch) | |
tree | effd57e9cfba2211aebb7f6419796e49b40dc1f6 /sonar-server | |
parent | 7f99c3f633353a98878103d5a5c99001745ce422 (diff) | |
download | sonarqube-787529a7ec4a567a31b375f76954ea31714a7c86.tar.gz sonarqube-787529a7ec4a567a31b375f76954ea31714a7c86.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java b/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java index 58e2d5ad0ad..9b971a24dc9 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java @@ -98,29 +98,28 @@ public final class ClassLoaderUtils { rootPath = StringUtils.removeStart(rootPath, "/"); URL root = classLoader.getResource(rootPath); - if (root == null) { - return paths; - } - if (!"jar".equals(root.getProtocol())) { - throw new IllegalStateException("Unsupported protocol: " + root.getProtocol()); - } + if (root != null) { + if (!"jar".equals(root.getProtocol())) { + throw new IllegalStateException("Unsupported protocol: " + root.getProtocol()); + } - // Path of the root directory - // Examples : - // org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale - // org/sonar/sqale/ -> rootDirectory is org/sonar/sqale - // org/sonar/sqale -> rootDirectory is org/sonar/sqale - String rootDirectory = rootPath; - if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) { - rootDirectory = StringUtils.substringBeforeLast(rootPath, "/"); - } - String jarPath = root.getPath().substring(5, root.getPath().indexOf("!")); //strip out only the JAR file - JarFile jar = new JarFile(URLDecoder.decode(jarPath, CharEncoding.UTF_8)); - Enumeration<JarEntry> entries = jar.entries(); - while (entries.hasMoreElements()) { - String name = entries.nextElement().getName(); - if (name.startsWith(rootDirectory) && predicate.apply(name)) { - paths.add(name); + // Path of the root directory + // Examples : + // org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale + // org/sonar/sqale/ -> rootDirectory is org/sonar/sqale + // org/sonar/sqale -> rootDirectory is org/sonar/sqale + String rootDirectory = rootPath; + if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) { + rootDirectory = StringUtils.substringBeforeLast(rootPath, "/"); + } + String jarPath = root.getPath().substring(5, root.getPath().indexOf("!")); //strip out only the JAR file + JarFile jar = new JarFile(URLDecoder.decode(jarPath, CharEncoding.UTF_8)); + Enumeration<JarEntry> entries = jar.entries(); + while (entries.hasMoreElements()) { + String name = entries.nextElement().getName(); + if (name.startsWith(rootDirectory) && predicate.apply(name)) { + paths.add(name); + } } } return paths; |