Permalink
Browse files

S4-66 Check for indirect extension of s4.App

In case of failure throw exception instead of stopping the process
  • Loading branch information...
1 parent dd1da04 commit 858a8aff138f296297982fda482ead357e86a018 Daniel Gómez Ferro committed Mar 7, 2013
@@ -42,11 +42,11 @@ public static void main(String[] args) {
params.add("appName=" + packageArgs.appName.get(0));
ExecGradle.exec(packageArgs.gradleBuildFile, "installS4R", params.toArray(new String[] {}));
- // Explicitly shutdown the JVM since Gradle leaves non-daemon threads running that delay the termination
- System.exit(0);
} catch (Exception e) {
LoggerFactory.getLogger(Package.class).error("Cannot deploy app", e);
}
+ // Explicitly shutdown the JVM since Gradle leaves non-daemon threads running that delay the termination
+ System.exit(0);
}
@Parameters(commandNames = "package", separators = "=", commandDescription = "Create s4r")
@@ -151,11 +151,11 @@ void checkAppClass() {
def appJar = project.libsDir.path+"/app/"+"$project.name"+".jar"
loader.addURL(new URL("file://"+appJar))
- def instance = Class.forName(appClassName, true, this.getClass().getClassLoader()).newInstance()
+ def userClass = Class.forName(appClassName, true, this.getClass().getClassLoader())
+ def appClass = Class.forName('org.apache.s4.core.App', true, this.getClass().getClassLoader())
- if (!(instance.getClass().getSuperclass().getName() == 'org.apache.s4.core.App') ){
- println "App class " + appClassName + " does not extend org.apache.s4.core.App!"
- System.exit(1)
+ if (!(appClass.isAssignableFrom(userClass))){
+ throw new InvalidUserDataException("App class " + appClassName + " does not extend org.apache.s4.core.App")
}
}

0 comments on commit 858a8af

Please sign in to comment.