You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mm...@apache.org on 2001/06/20 01:04:39 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ServletWrapper.java

mmanders    01/06/19 16:04:39

  Modified:    src/share/org/apache/tomcat/core Tag: tomcat_32
                        ServletWrapper.java
  Log:
  Syncronized around call to loader.shouldReload to prevent getting the loader in an invalid state.  Fixes Bug # 1628.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.60.2.6  +38 -32    jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ServletWrapper.java,v
  retrieving revision 1.60.2.5
  retrieving revision 1.60.2.6
  diff -u -r1.60.2.5 -r1.60.2.6
  --- ServletWrapper.java	2001/01/12 04:39:05	1.60.2.5
  +++ ServletWrapper.java	2001/06/19 23:04:38	1.60.2.6
  @@ -422,38 +422,44 @@
   	if( isReloadable ) {// && ! "invoker".equals( getServletName())) {
   	    ServletLoader loader=context.getServletLoader();
   	    if( loader!=null) {
  -		// XXX no need to check after we remove the old loader
  -		if( loader.shouldReload() ) {
  -		    // workaround for destroy 
  -		    try {
  -			destroy();
  -		    } catch(Exception ex ) {
  -			context.log( "Error in destroy ", ex );
  -		    }
  -		    initialized=false;
  -		    loader.reload();
  -		    
  -		    ContextManager cm=context.getContextManager();
  -		    cm.doReload( req, context );
  -		    
  -		    servlet=null;
  -		    servletClass=null;
  -		    /* Initial attempt to shut down the context and sessions.
  -		       
  -		       String path=context.getPath();
  -		       String docBase=context.getDocBase();
  -		       // XXX all other properties need to be saved
  -		       // or something else
  -		       ContextManager cm=context.getContextManager();
  -		       cm.removeContext(path);
  -		       Context ctx=new Context();
  -		       ctx.setPath( path );
  -		       ctx.setDocBase( docBase );
  -		       cm.addContext( ctx );
  -		       context=ctx;
  -		       // XXX shut down context, remove sessions, etc
  -		    */
  -		}
  +                // We need to syncronize here so that multiple threads don't
  +                // try and reload the class.  The first thread through will
  +                // create the new loader which will make shouldReload return
  +                // false for subsequent threads.
  +                synchronized(this) {
  +                    // XXX no need to check after we remove the old loader
  +                    if( loader.shouldReload() ) {
  +                        // workaround for destroy 
  +                        try {
  +                            destroy();
  +                        } catch(Exception ex ) {
  +                            context.log( "Error in destroy ", ex );
  +                        }
  +                        initialized=false;
  +                        loader.reload();
  +                        
  +                        ContextManager cm=context.getContextManager();
  +                        cm.doReload( req, context );
  +                        
  +                        servlet=null;
  +                        servletClass=null;
  +                        /* Initial attempt to shut down the context and sessions.
  +                           
  +                           String path=context.getPath();
  +                           String docBase=context.getDocBase();
  +                           // XXX all other properties need to be saved
  +                           // or something else
  +                           ContextManager cm=context.getContextManager();
  +                           cm.removeContext(path);
  +                           Context ctx=new Context();
  +                           ctx.setPath( path );
  +                           ctx.setDocBase( docBase );
  +                           cm.addContext( ctx );
  +                           context=ctx;
  +                           // XXX shut down context, remove sessions, etc
  +                        */
  +                    }
  +                }
   	    }
   	}
       }