Skip to content

Commit

Permalink
CID-1116298 path can be null, make sure that is properly handled
Browse files Browse the repository at this point in the history
  • Loading branch information
spark404 committed Sep 19, 2014
1 parent 6687727 commit 6f54d48
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions utils/src/com/cloud/utils/script/Script.java
Expand Up @@ -308,7 +308,7 @@ public static class Task implements Runnable {
public Task(OutputInterpreter interpreter, BufferedReader reader) {
this.interpreter = interpreter;
this.reader = reader;
this.result = null;
result = null;
}

@Override
Expand Down Expand Up @@ -340,8 +340,6 @@ public synchronized String getResult() throws InterruptedException {
public static String findScript(String path, String script) {
s_logger.debug("Looking for " + script + " in the classpath");

path = path.replace("/", File.separator);

URL url = ClassLoader.getSystemResource(script);
s_logger.debug("System resource: " + url);
File file = null;
Expand All @@ -351,6 +349,12 @@ public static String findScript(String path, String script) {
return file.getAbsolutePath();
}

if (path == null) {
s_logger.warn("No search path specified, unable to look for " + script);
return null;
}
path = path.replace("/", File.separator);

/**
* Look in WEB-INF/classes of the webapp
* URI workaround the URL encoding of url.getFile
Expand Down

0 comments on commit 6f54d48

Please sign in to comment.