tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardWrapper.java
Date Sat, 23 Jun 2001 21:56:38 GMT
remm        01/06/23 14:56:38

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardWrapper.java
  Log:
  - Make sure the old CL is bound after loading the servlet class. If there was
    an exception, the new CL could remain bound.
  
  Revision  Changes    Path
  1.25      +40 -13    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java
  
  Index: StandardWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- StandardWrapper.java	2001/05/14 04:51:19	1.24
  +++ StandardWrapper.java	2001/06/23 21:56:38	1.25
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
1.24 2001/05/14 04:51:19 craigmcc Exp $
  - * $Revision: 1.24 $
  - * $Date: 2001/05/14 04:51:19 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
1.25 2001/06/23 21:56:38 remm Exp $
  + * $Revision: 1.25 $
  + * $Date: 2001/06/23 21:56:38 $
    *
    * ====================================================================
    *
  @@ -105,7 +105,7 @@
    * make them efficient are counter-productive.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.24 $ $Date: 2001/05/14 04:51:19 $
  + * @version $Revision: 1.25 $ $Date: 2001/06/23 21:56:38 $
    */
   
   public final class StandardWrapper
  @@ -785,24 +785,39 @@
               log(sm.getString("standardWrapper.jasperLoader", getName()));
           }
   
  +        // Set the context class loader
  +        if (classLoader != null) {
  +            Thread.currentThread().setContextClassLoader(classLoader);
  +        }
  +
   	// Load the specified servlet class from the appropriate class loader
   	Class classClass = null;
   	try {
  -	    if (classLoader != null)
  +	    if (classLoader != null) {
   		classClass = classLoader.loadClass(actualClass);
  -	    else
  +	    } else {
   		classClass = Class.forName(actualClass);
  +            }
   	} catch (ClassNotFoundException e) {
   	    unavailable(null);
  +            // Restore the context ClassLoader
  +	    if (classLoader != null) {
  +                Thread.currentThread().setContextClassLoader
  +                    (oldCtxClassLoader);
  +            }
   	    throw new ServletException
   		(sm.getString("standardWrapper.missingClass", actualClass),
   		 e);
   	}
   	if (classClass == null) {
  -	    unavailable(null);
  -	    throw new ServletException
  -		(sm.getString("standardWrapper.missingClass", actualClass));
  -	}
  +            unavailable(null);
  +            if (classLoader != null) {
  +                Thread.currentThread().setContextClassLoader
  +                    (oldCtxClassLoader);
  +            }
  +            throw new ServletException
  +                (sm.getString("standardWrapper.missingClass", actualClass));
  +        }
   
   	// Instantiate and initialize an instance of the servlet class itself
   	Servlet servlet = null;
  @@ -810,10 +825,20 @@
   	    servlet = (Servlet) classClass.newInstance();
   	} catch (ClassCastException e) {
   	    unavailable(null);
  +            // Restore the context ClassLoader
  +	    if (classLoader != null) {
  +                Thread.currentThread().setContextClassLoader
  +                    (oldCtxClassLoader);
  +            }
   	    throw new ServletException
   		(sm.getString("standardWrapper.notServlet", actualClass), e);
   	} catch (Throwable e) {
   	    unavailable(null);
  +            // Restore the context ClassLoader
  +	    if (classLoader != null) {
  +                Thread.currentThread().setContextClassLoader
  +                    (oldCtxClassLoader);
  +            }
   	    throw new ServletException
   		(sm.getString("standardWrapper.instantiate", actualClass), e);
   	}
  @@ -829,7 +854,6 @@
   	try {
   	    instanceSupport.fireInstanceEvent(InstanceEvent.BEFORE_INIT_EVENT,
   					      servlet);
  -            Thread.currentThread().setContextClassLoader(classLoader);
   	    servlet.init(facade);
   	    instanceSupport.fireInstanceEvent(InstanceEvent.AFTER_INIT_EVENT,
   					      servlet);
  @@ -852,8 +876,11 @@
   	    throw new ServletException
   		(sm.getString("standardWrapper.initException", getName()), f);
   	} finally {
  -            // restore the context ClassLoader
  -            Thread.currentThread().setContextClassLoader(oldCtxClassLoader);
  +            // Restore the context ClassLoader
  +            if (classLoader != null) {
  +                Thread.currentThread().setContextClassLoader
  +                    (oldCtxClassLoader);
  +            }
           }
   
   	// Register our newly initialized instance
  
  
  

Mime
View raw message