You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/06/23 21:25:24 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core ApplicationContext.java StandardContext.java

craigmcc    01/06/23 12:25:24

  Modified:    catalina/src/share/org/apache/catalina/core
                        ApplicationContext.java StandardContext.java
  Log:
  Add a call to clear any application-originated context attributes during a
  restart, in order to avoid dangling references to object instances created
  by the old class loader (after a reload, you would get a
  ClassCastException trying to access such an attribute).
  
  HOWEVER:  The call to clearAttributes() is currently commented out,
  because it causes ClassNotFoundexceptions trying to restart listeners and
  filters, for a reason I cannot fathom yet, on the test suite additions to
  be checked in next.
  
  There is also an additional problem -- we're not re-init()-ing the load on
  startup servlets after a restart.  That will be fixed once we figure out
  what's going on with clearing attributes.
  
  Revision  Changes    Path
  1.28      +32 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
  
  Index: ApplicationContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ApplicationContext.java	2001/05/21 19:53:56	1.27
  +++ ApplicationContext.java	2001/06/23 19:25:24	1.28
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v 1.27 2001/05/21 19:53:56 craigmcc Exp $
  - * $Revision: 1.27 $
  - * $Date: 2001/05/21 19:53:56 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v 1.28 2001/06/23 19:25:24 craigmcc Exp $
  + * $Revision: 1.28 $
  + * $Date: 2001/06/23 19:25:24 $
    *
    * ====================================================================
    *
  @@ -79,6 +79,7 @@
   import java.util.Enumeration;
   import java.util.HashMap;
   import java.util.HashSet;
  +import java.util.Iterator;
   import java.util.Set;
   import javax.naming.NamingException;
   import javax.naming.Binding;
  @@ -112,7 +113,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.27 $ $Date: 2001/05/21 19:53:56 $
  + * @version $Revision: 1.28 $ $Date: 2001/06/23 19:25:24 $
    */
   
   public class ApplicationContext
  @@ -322,6 +323,32 @@
   
   
       /**
  +     * Clear all application-created attributes.
  +     */
  +    public void clearAttributes() {
  +
  +        // Create list of attributes to be removed
  +        ArrayList list = new ArrayList();
  +        synchronized (attributes) {
  +            Iterator iter = attributes.keySet().iterator();
  +            while (iter.hasNext()) {
  +                list.add(iter.next());
  +            }
  +        }
  +
  +        // Remove application originated attributes
  +        // (read only attributes will be left in place)
  +        Iterator keys = list.iterator();
  +        while (keys.hasNext()) {
  +            String key = (String) keys.next();
  +            removeAttribute(key);
  +        }
  +
  +
  +    }
  +
  +
  +    /**
        * Return the resources object that is mapped to a specified path.
        * The path must begin with a "/" and is interpreted as relative to the
        * current context root.
  @@ -833,7 +860,7 @@
   	// Remove the specified attribute
   	synchronized (attributes) {
               // Check for read only attribute
  -            if (readOnlyAttributes.containsKey(name))
  +           if (readOnlyAttributes.containsKey(name))
                   return;
               found = attributes.containsKey(name);
               if (found) {
  
  
  
  1.64      +10 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- StandardContext.java	2001/06/19 02:14:48	1.63
  +++ StandardContext.java	2001/06/23 19:25:24	1.64
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v 1.63 2001/06/19 02:14:48 remm Exp $
  - * $Revision: 1.63 $
  - * $Date: 2001/06/19 02:14:48 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v 1.64 2001/06/23 19:25:24 craigmcc Exp $
  + * $Revision: 1.64 $
  + * $Date: 2001/06/23 19:25:24 $
    *
    * ====================================================================
    *
  @@ -141,7 +141,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.63 $ $Date: 2001/06/19 02:14:48 $
  + * @version $Revision: 1.64 $ $Date: 2001/06/23 19:25:24 $
    */
   
   public class StandardContext
  @@ -2299,10 +2299,15 @@
   	    }
   	}
   
  +        // Unbinding thread
           if (isUseNaming()) {
               ContextBindings.unbindThread(this, this);
           }
   
  +        // Clear all application-originated servlet context attributes
  +        //        if (context != null)
  +        //            context.clearAttributes();
  +
           // Shut down filters and application event listeners
           filterStop();
           listenerStop();
  @@ -2392,12 +2397,12 @@
   
   	// Start accepting requests again
           if (ok) {
  -            setPaused(false);
               log(sm.getString("standardContext.reloadingCompleted"));
           } else {
               setAvailable(false);
               log(sm.getString("standardContext.reloadingFailed"));
           }
  +        setPaused(false);
   
       }