Avoid a NPE on certain kinds missing included resources, and instead give a helpful error along the lines of other include issues

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28711 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-06-29 22:30:53 +00:00
parent f198084c66
commit b4fbb4cac6

View File

@@ -21,6 +21,7 @@ package org.alfresco.repo.jscript;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -321,7 +322,12 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
{
// load from classpath
String scriptClasspath = resource.substring(PATH_CLASSPATH.length());
InputStream stream = getClass().getClassLoader().getResource(scriptClasspath).openStream();
URL scriptResource = getClass().getClassLoader().getResource(scriptClasspath);
if (scriptResource == null)
{
throw new AlfrescoRuntimeException("Unable to locate included script classpath resource: " + resource);
}
InputStream stream = scriptResource.openStream();
if (stream == null)
{
throw new AlfrescoRuntimeException("Unable to load included script classpath resource: " + resource);