464438 ClassFileTransformer support in org.eclipse.jetty.webapp.WebAppClassLoader broken
This commit is contained in:
parent
4fbdafb9e9
commit
92a3f17532
|
@ -519,10 +519,14 @@ public class WebAppClassLoader extends URLClassLoader
|
|||
try
|
||||
{
|
||||
content = url.openStream();
|
||||
byte[] bytes =IO.readBytes(content);
|
||||
byte[] bytes = IO.readBytes(content);
|
||||
|
||||
for (ClassFileTransformer transformer : _transformers)
|
||||
bytes=transformer.transform(this,name,null,null,bytes);
|
||||
{
|
||||
byte[] tmp = transformer.transform(this,name,null,null,bytes);
|
||||
if (tmp != null)
|
||||
bytes = tmp;
|
||||
}
|
||||
|
||||
clazz=defineClass(name,bytes,0,bytes.length);
|
||||
}
|
||||
|
|
|
@ -137,7 +137,22 @@ public class WebAppClassLoaderTest
|
|||
assertEquals(_loader,iter.next());
|
||||
assertEquals("org.acme.other.ClassInClassesC",iter.next());
|
||||
assertFalse(iter.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullClassFileTransformer () throws Exception
|
||||
{
|
||||
_loader.addTransformer(new ClassFileTransformer()
|
||||
{
|
||||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
|
||||
throws IllegalClassFormatException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
assertTrue(canLoadClass("org.acme.webapp.ClassInJarA"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue