| From | Sent On | Attachments |
|---|---|---|
| mar...@apache.org | Feb 8, 2012 1:19 pm | |
| Konstantin Kolinko | Mar 20, 2012 8:40 am | |
| Mark Thomas | Mar 20, 2012 1:14 pm |
| Subject: | Re: svn commit: r1242101 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/core/StandardServer.java java/org/apache/catalina/util/ExtensionValidator.java webapps/docs/changelog.xml | |
|---|---|---|
| From: | Konstantin Kolinko (knst...@gmail.com) | |
| Date: | Mar 20, 2012 8:40:50 am | |
| List: | org.apache.tomcat.dev | |
2012/2/9 <mar...@apache.org>:
Author: markt Date: Wed Feb 8 21:19:36 2012 New Revision: 1242101
URL: http://svn.apache.org/viewvc?rev=1242101&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52607 The ExtensionValidator needs to be aware of the classes in the shared and common loaders.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ExtensionValidator.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Feb 8 21:19:36 2012
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java?rev=1242101&r1=1242100&r2=1242101&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java Wed
Feb 8 21:19:36 2012
@@ -18,11 +18,15 @@ package org.apache.catalina.core;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLClassLoader; import java.security.AccessControlException; import java.util.Random;
@@ -37,6 +41,7 @@ import org.apache.catalina.deploy.Naming import org.apache.catalina.mbeans.MBeanFactory; import org.apache.catalina.mbeans.MBeanUtils; import org.apache.catalina.startup.Catalina; +import org.apache.catalina.util.ExtensionValidator; import org.apache.catalina.util.LifecycleMBeanBase; import org.apache.catalina.util.ServerInfo; import org.apache.juli.logging.Log; @@ -776,6 +781,35 @@ public final class StandardServer extend // Register the naming resources globalNamingResources.init();
+ // Populate the extension validator with JARs from common and shared + // class loaders + if (getCatalina() != null) { + ClassLoader cl = + getCatalina().getParentClassLoader();
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.
+ // 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.
+ 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
+ } + } catch (URISyntaxException e) { + // Ignore + } catch (IOException e) { + // Ignore + } + } + } + } + cl = cl.getParent(); + } + } // Initialize our defined Services for (int i = 0; i < services.length; i++) { services[i].init();
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ExtensionValidator.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ExtensionValidator.java?rev=1242101&r1=1242100&r2=1242101&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ExtensionValidator.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ExtensionValidator.java
Wed Feb 8 21:19:36 2012
@@ -107,8 +107,6 @@ public final class ExtensionValidator {
// add specified folders to the list addFolderList("java.ext.dirs"); - addFolderList("catalina.ext.dirs"); - }
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1242101&r1=1242100&r2=1242101&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed Feb 8 21:19:36 2012
@@ -119,6 +119,10 @@
<bug>52591</bug>: When dumping MBean data, skip attributes where getters
throw <code>UnsupportedOperationException</code>. (markt)
</fix>
+ <fix>
+ <bug>52607</bug>: Ensure that the extension validator checks the JARs
in
+ the shared and common class loaders for extensions. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
Best regards, Konstantin Kolinko





