dgraham     2003/07/07 17:50:54

  Modified:    src/share/org/apache/struts/action ActionServlet.java
  Log:
  Added a getProcessorForModule() method that won't create a 
  RequestProcessor when one doesn't exist.  Call this method from 
  destroyModules() instead of getRequestProcessor() for PR# 21337.
  
  Revision  Changes    Path
  1.161     +20 -12    
jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.160
  retrieving revision 1.161
  diff -u -r1.160 -r1.161
  --- ActionServlet.java        8 Jul 2003 00:39:21 -0000       1.160
  +++ ActionServlet.java        8 Jul 2003 00:50:54 -0000       1.161
  @@ -534,11 +534,9 @@
               }
               
               ModuleConfig config = (ModuleConfig) value;
  -            try {
  -                getRequestProcessor(config).destroy();
  -                
  -            } catch (ServletException e) {
  -                log.error(e);
  +
  +            if (this.getProcessorForModule(config) != null) {
  +                this.getProcessorForModule(config).destroy();
               }
   
               getServletContext().removeAttribute(name);
  @@ -616,9 +614,7 @@
       protected synchronized RequestProcessor getRequestProcessor(ModuleConfig config)
           throws ServletException {    
               
  -        String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
  -        RequestProcessor processor = (RequestProcessor)
  -            getServletContext().getAttribute(key);
  +        RequestProcessor processor = this.getProcessorForModule(config);
               
           if (processor == null) {
               try {
  @@ -635,11 +631,23 @@
               }
   
               processor.init(this, config);
  +            
  +            String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
               getServletContext().setAttribute(key, processor);
   
           }
  +        
           return (processor);
   
  +    }
  +    
  +    /**
  +     * Returns the RequestProcessor for the given module or null if one does not 
  +     * exist.  This method will not create a RequestProcessor.
  +     */
  +    private RequestProcessor getProcessorForModule(ModuleConfig config) {
  +        String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
  +        return (RequestProcessor) getServletContext().getAttribute(key);
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to