Skip to content

Commit

Permalink
1.0.22 - Fixing bug where nothing worked #20
Browse files Browse the repository at this point in the history
Adding the /rippers/video subdirectory package caused the
auto-class-finder to try to initialize a class that did not exist (dir
name instead of class name).
  • Loading branch information
4pr0n committed Apr 21, 2014
1 parent 0916252 commit d5822b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId>
<packaging>jar</packaging>
<version>1.0.21</version>
<version>1.0.22</version>
<name>ripme</name>
<url>http://rip.rarchives.com</url>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rarchives/ripme/ui/UpdateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class UpdateUtils {

private static final Logger logger = Logger.getLogger(UpdateUtils.class);
private static final String DEFAULT_VERSION = "1.0.21";
private static final String DEFAULT_VERSION = "1.0.22";
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
private static final String mainFileName = "ripme.jar";
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/rarchives/ripme/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,25 @@ public static ArrayList<Class<?>> getClassesForPackage(String pkgname) {
}
}
else {
// Load from JAR
try {
logger.debug("fullPath = " + fullPath);
String jarPath = fullPath
.replaceFirst("[.]jar[!].*", ".jar")
.replaceFirst("file:", "")
.replaceAll("%20", " ");
logger.debug("jarPath = " + jarPath);
JarFile jarFile = new JarFile(jarPath);
Enumeration<JarEntry> entries = jarFile.entries();
while(entries.hasMoreElements()) {
String entryName = entries.nextElement().getName();
JarEntry nextElement = entries.nextElement();
String entryName = nextElement.getName();
if(entryName.startsWith(relPath)
&& entryName.length() > (relPath.length() + "/".length())) {
&& entryName.length() > (relPath.length() + "/".length())
&& !nextElement.isDirectory()) {

This comment has been minimized.

Copy link
@4pr0n

4pr0n Apr 21, 2014

Author Owner

Here we check if the element is a directory or not (!). We don't want to create/add a class that's named after a directory -- that doesn't make any sense.

The silent failure is bad and difficult to track down. Added error message but this method should skip over failed classNames instead of breaking the whole method.

String className = entryName.replace('/', '.').replace('\\', '.').replace(".class", "");
try {
classes.add(Class.forName(className));
} catch (ClassNotFoundException e) {
logger.error("ClassNotFoundException loading " + className);
throw new RuntimeException("ClassNotFoundException loading " + className);
}
}
Expand Down

0 comments on commit d5822b3

Please sign in to comment.