415118 WebAppClassLoader.getResource(name) should strip .class from name
This commit is contained in:
parent
d5f83a8159
commit
6ef9108cf6
|
@ -336,8 +336,15 @@ public class WebAppClassLoader extends URLClassLoader
|
|||
{
|
||||
URL url= null;
|
||||
boolean tried_parent= false;
|
||||
boolean system_class=_context.isSystemClass(name);
|
||||
boolean server_class=_context.isServerClass(name);
|
||||
|
||||
//If the resource is a class name with .class suffix, strip it off before comparison
|
||||
//as the server and system patterns are specified without a .class suffix
|
||||
String tmp = name;
|
||||
if (tmp != null && tmp.endsWith(".class"))
|
||||
tmp = tmp.substring(0, tmp.length()-6);
|
||||
|
||||
boolean system_class=_context.isSystemClass(tmp);
|
||||
boolean server_class=_context.isServerClass(tmp);
|
||||
|
||||
if (system_class && server_class)
|
||||
return null;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URL;
|
||||
|
@ -121,9 +122,24 @@ public class WebAppClassLoaderTest
|
|||
assertTrue(canLoadClass("org.acme.webapp.ClassInJarA"));
|
||||
assertTrue(canLoadClass("org.acme.webapp.ClassInJarB"));
|
||||
assertTrue(canLoadClass("org.acme.other.ClassInClassesC"));
|
||||
|
||||
assertTrue(cantLoadClass("org.eclipse.jetty.webapp.Configuration"));
|
||||
assertTrue(cantLoadClass("org.eclipse.jetty.webapp.JarScanner"));
|
||||
|
||||
oldSysC=_context.getSystemClasses();
|
||||
newSysC=new String[oldSysC.length+1];
|
||||
newSysC[0]="org.acme.webapp.ClassInJarA";
|
||||
System.arraycopy(oldSysC,0,newSysC,1,oldSysC.length);
|
||||
_context.setSystemClasses(newSysC);
|
||||
|
||||
assertNotNull(_loader.getResource("org/acme/webapp/ClassInJarA.class"));
|
||||
_context.setSystemClasses(oldSysC);
|
||||
|
||||
oldServC=_context.getServerClasses();
|
||||
newServC=new String[oldServC.length+1];
|
||||
newServC[0]="org.acme.webapp.ClassInJarA";
|
||||
System.arraycopy(oldServC,0,newServC,1,oldServC.length);
|
||||
_context.setServerClasses(newServC);
|
||||
assertNotNull(_loader.getResource("org/acme/webapp/ClassInJarA.class"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue