tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Luehe <Jan.Lu...@Sun.COM>
Subject Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader WebappClassLoader.java
Date Wed, 28 Sep 2005 17:08:54 GMT
Remy,

Remy Maucherat wrote On 09/28/05 03:12,:
> jfarcand@apache.org wrote:
> 
>>  +        /*
>>  +         * Clear the IntrospectionUtils cache.
>>  +         *
>>  +         * Implementation note:
>>  +         * Any reference to IntrospectionUtils which may cause the static
>>  +         * initalizer of that class to be invoked must occur prior to setting
>>  +         * the started flag to FALSE, because the static initializer of
>>  +         * IntrospectionUtils makes a call to
>>  +         * org.apache.commons.logging.LogFactory.getLog(), which ultimately
>>  +         * calls the loadClass() method of the thread context classloader,
>>  +         * which is the same as this classloader, whose impl throws a
>>  +         * ThreadDeath if the started flag has been set to FALSE.
>>  +         */
>>  +        IntrospectionUtils.clear();
>>  +
> 
> 
> This commit does not make sense to me. The static initializer is called 
> when loading the class, and obviously the webapp CL is not going to load 
> IntrospectionUtils.

This code in IntrospectionUtils.java:

    private static org.apache.commons.logging.Log log=
        org.apache.commons.logging.LogFactory.getLog(
            IntrospectionUtils.class );

will cause LogFactoryImpl.getLogConstructor() to be called, which
in turn will invoke LogFactoryImpl.loadClass(String name), which is
implemented as follows:

    private static Class loadClass( final String name )
        throws ClassNotFoundException
    {
        Object result = AccessController.doPrivileged(
            new PrivilegedAction() {
                public Object run() {
                    ClassLoader threadCL = getContextClassLoader();
                    if (threadCL != null) {
                        try {
                            return threadCL.loadClass(name);
                        } catch( ClassNotFoundException ex ) {
                            // ignore
                        }
                    }
                    try {
                        return Class.forName( name );
                    } catch (ClassNotFoundException e) {
                        return e;
                    }
                }
            });

        if (result instanceof Class)
            return (Class)result;

        throw (ClassNotFoundException)result;
    }

Notice the use of the thread context classloader (to load the class
with the given name), which is the same as the WebappClassLoader.

WebappClassLoader.loadClass() has this:

    // Don't load classes if class loader is stopped
    if (!started) {
        log.info(sm.getString("webappClassLoader.stopped"));
        throw new ThreadDeath();
    }

We have seen the ThreadDeath in our callstacks, hence this fix.

Jan


> You should forget that the CVS exists, as we're in the middle of 
> migrating to SVN (of course, losing that commit will not be a problem).
> 
> Rémy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message