Skip to content

Commit

Permalink
Fixes #5521 ResourceCollection NPE
Browse files Browse the repository at this point in the history
Revert adding paths ending in / as jar:file resource needs them
  • Loading branch information
gregw committed Oct 28, 2020
1 parent 288340a commit ae4f9f6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Expand Up @@ -658,8 +658,8 @@ public void multipleResourcesHandler() throws Exception

// For multiple directories, use ResourceCollection.
ResourceCollection directories = new ResourceCollection();
directories.addPath("/path/to/static/resources");
directories.addPath("/another/path/to/static/resources");
directories.addPath("/path/to/static/resources/");
directories.addPath("/another/path/to/static/resources/");

handler.setBaseResource(directories);
// end::multipleResourcesHandler[]
Expand Down
Expand Up @@ -766,7 +766,7 @@ protected List<Resource> findWebInfLibJars(WebAppContext context)
return null;

List<Resource> jarResources = new ArrayList<Resource>();
Resource webInfLib = webInf.addPath("lib");
Resource webInfLib = webInf.addPath("/lib");
if (webInfLib.exists() && webInfLib.isDirectory())
{
String[] files = webInfLib.list();
Expand Down Expand Up @@ -834,7 +834,7 @@ protected Resource findWebInfClassesDir(WebAppContext context)
if (webInf != null && webInf.isDirectory())
{
// Look for classes directory
Resource classes = webInf.addPath("classes");
Resource classes = webInf.addPath("classes/");
if (classes.exists())
return classes;
}
Expand Down
Expand Up @@ -834,7 +834,7 @@ public Resource getWebInf() throws IOException
return null;

// Iw there a WEB-INF directory?
Resource webInf = super.getBaseResource().addPath("WEB-INF");
Resource webInf = super.getBaseResource().addPath("WEB-INF/");
if (!webInf.exists() || !webInf.isDirectory())
return null;

Expand Down
Expand Up @@ -70,12 +70,12 @@ public void configure(WebAppContext context) throws Exception
if (webInf != null && webInf.isDirectory() && context.getClassLoader() instanceof WebAppClassLoader)
{
// Look for classes directory
Resource classes = webInf.addPath("classes");
Resource classes = webInf.addPath("classes/");
if (classes.exists())
((WebAppClassLoader)context.getClassLoader()).addClassPath(classes);

// Look for jars
Resource lib = webInf.addPath("lib");
Resource lib = webInf.addPath("lib/");
if (lib.exists() || lib.isDirectory())
((WebAppClassLoader)context.getClassLoader()).addJars(lib);
}
Expand Down Expand Up @@ -413,13 +413,13 @@ public void unpack(WebAppContext context) throws IOException
// Do we need to extract WEB-INF/lib?
if (context.isCopyWebInf() && !context.isCopyWebDir())
{
Resource webInf = webApp.addPath("WEB-INF");
Resource webInf = webApp.addPath("WEB-INF/");

File extractedWebInfDir = new File(context.getTempDirectory(), "webinf");
if (extractedWebInfDir.exists())
IO.delete(extractedWebInfDir);
extractedWebInfDir.mkdir();
Resource webInfLib = webInf.addPath("lib");
Resource webInfLib = webInf.addPath("lib/");
File webInfDir = new File(extractedWebInfDir, "WEB-INF");
webInfDir.mkdir();

Expand All @@ -435,7 +435,7 @@ public void unpack(WebAppContext context) throws IOException
webInfLib.copyTo(webInfLibDir);
}

Resource webInfClasses = webInf.addPath("classes");
Resource webInfClasses = webInf.addPath("classes/");
if (webInfClasses.exists())
{
File webInfClassesDir = new File(webInfDir, "classes");
Expand Down

0 comments on commit ae4f9f6

Please sign in to comment.