Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x

This commit is contained in:
Jan Bartel 2019-02-06 17:58:23 +11:00
commit 08f1969f64
5 changed files with 20 additions and 3 deletions

View File

@ -279,12 +279,20 @@ public class WebAppClassLoader extends URLClassLoader
StringTokenizer tokenizer= new StringTokenizer(classPath, ",;");
while (tokenizer.hasMoreTokens())
{
Resource resource= _context.newResource(tokenizer.nextToken().trim());
String token = tokenizer.nextToken().trim();
Resource resource= _context.newResource(token);
if (LOG.isDebugEnabled())
LOG.debug("Path resource=" + resource);
// Add the resource
if (resource.isDirectory() && resource instanceof ResourceCollection)
if(token.endsWith("*"))
{
if(token.length() > 1)
{
token = token.substring(0, token.length() - 1);
resource= _context.newResource(token);
addJars(resource);
}
} else if (resource.isDirectory() && resource instanceof ResourceCollection)
addClassPath(resource);
else
{

View File

@ -65,6 +65,7 @@ public class WebAppClassLoaderTest
_context = new WebAppContext();
_context.setBaseResource(webapp);
_context.setContextPath("/test");
_context.setExtraClasspath("src/test/resources/ext/*");
_loader = new WebAppClassLoader(_context);
_loader.addJars(webapp.addPath("WEB-INF/lib"));
@ -105,6 +106,10 @@ public class WebAppClassLoaderTest
assertCanLoadClass("org.acme.webapp.ClassInJarB");
assertCanLoadClass("org.acme.other.ClassInClassesC");
assertCanLoadClass("org.acme.extone.Main");
assertCanLoadClass("org.acme.exttwo.Main");
assertCantLoadClass("org.acme.extthree.Main");
assertCantLoadClass("org.eclipse.jetty.webapp.Configuration");
Class<?> clazzA = _loader.loadClass("org.acme.webapp.ClassInJarA");
@ -119,6 +124,10 @@ public class WebAppClassLoaderTest
assertCanLoadClass("org.acme.webapp.ClassInJarB");
assertCanLoadClass("org.acme.other.ClassInClassesC");
assertCanLoadClass("org.acme.extone.Main");
assertCanLoadClass("org.acme.exttwo.Main");
assertCantLoadClass("org.acme.extthree.Main");
assertCantLoadClass("org.eclipse.jetty.webapp.Configuration");
Class<?> clazzA = _loader.loadClass("org.acme.webapp.ClassInJarA");