On 20/03/2012 15:41, Konstantin Kolinko wrote:
1). Why isn't is starting with this.getParentClassLoader(); ?
The actual shared classloader is the one used in
WebappLoader#createClassLoader(). I'd say that calling
Server.getParentClassLoader() will be closer to the truth here.
E.g. Tomcat class creates and calls Server instance directly, without
relying on Catalina. So using Server.getParentClassLoader() seems to
be better here.
+1 to that change.
+ // Walk the class loader hierarchy. Stop at the system class
loader.
+ // This will add the shared (if present) and common class loaders
+ while (cl != ClassLoader.getSystemClassLoader()) {
2) It should not hurt to move ClassLoader.getSystemClassLoader() out
of the loop. This method involves a SecurityManager check and it is
better to do it once.
+1.
+ if (cl instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader) cl).getURLs();
+ for (URL url : urls) {
+ if (url.getProtocol().equals("file")) {
+ try {
+ File f = new File (url.toURI());
+ if (f.isFile() &&
+ f.getName().endsWith(".jar")) {
+ ExtensionValidator.addSystemResource(f);
3) The above is a static method and it does not check for duplicates.
It would be a substantial change to ExtensionValidator to fix it, so I
submitted the following issue:
https://issues.apache.org/bugzilla/show_bug.cgi?id=52952
Comments on bug.
Mark