Author: violetagg Date: Wed Sep 14 07:34:36 2016 New Revision: 1760648 URL: http://svn.apache.org/viewvc?rev=1760648&view=rev Log: Ensure Digester.useContextClassLoader is considered in case the class loader is used.
Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java?rev=1760648&r1=1760647&r2=1760648&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Wed Sep 14 07:34:36 2016 @@ -78,46 +78,25 @@ public class Digester extends DefaultHan // ---------------------------------------------------------- Static Fields - private static class SystemPropertySource implements IntrospectionUtils.PropertySource { - @Override - public String getProperty(String key) { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl instanceof PermissionCheck) { - Permission p = new PropertyPermission(key, "read"); - if (!((PermissionCheck) cl).check(p)) { - return null; - } - } - return System.getProperty(key); - } - } - protected static IntrospectionUtils.PropertySource source[] = new IntrospectionUtils.PropertySource[] { - new SystemPropertySource() }; + protected static IntrospectionUtils.PropertySource propertySource = null; static { String className = System.getProperty("org.apache.tomcat.util.digester.PROPERTY_SOURCE"); if (className != null) { - IntrospectionUtils.PropertySource[] sources = new IntrospectionUtils.PropertySource[2]; - sources[1] = source[0]; ClassLoader[] cls = new ClassLoader[] { Digester.class.getClassLoader(), Thread.currentThread().getContextClassLoader() }; - boolean initialized = false; - for (int i = 0; i < cls.length && (!initialized); i++) { + for (int i = 0; i < cls.length; i++) { try { Class<?> clazz = Class.forName(className, true, cls[i]); - IntrospectionUtils.PropertySource src = (IntrospectionUtils.PropertySource) clazz - .newInstance(); - sources[0] = src; - initialized = true; + propertySource = (IntrospectionUtils.PropertySource) clazz.newInstance(); + break; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); LogFactory.getLog("org.apache.tomcat.util.digester.Digester") .error("Unable to load property source[" + className + "].", t); } } - if (initialized) - source = sources; } } @@ -125,6 +104,25 @@ public class Digester extends DefaultHan // --------------------------------------------------- Instance Variables + private class SystemPropertySource implements IntrospectionUtils.PropertySource { + @Override + public String getProperty(String key) { + ClassLoader cl = getClassLoader(); + if (cl instanceof PermissionCheck) { + Permission p = new PropertyPermission(key, "read"); + if (!((PermissionCheck) cl).check(p)) { + return null; + } + } + return System.getProperty(key); + } + } + + + protected IntrospectionUtils.PropertySource source[] = new IntrospectionUtils.PropertySource[] { + new SystemPropertySource() }; + + /** * The body text of the current element. */ @@ -300,6 +298,13 @@ public class Digester extends DefaultHan protected Log saxLog = LogFactory.getLog("org.apache.tomcat.util.digester.Digester.sax"); + public Digester() { + if (propertySource != null) { + source = new IntrospectionUtils.PropertySource[] { propertySource, source[0] }; + } + } + + // ------------------------------------------------------------- Properties /** Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1760648&r1=1760647&r2=1760648&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Sep 14 07:34:36 2016 @@ -64,6 +64,10 @@ references evaluated in conditions to be forced to lower case when using the <code>NC</code> flag. (markt) </fix> + <fix> + Ensure <code>Digester.useContextClassLoader</code> is considered in + case the class loader is used. (violetagg) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org