tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardWrapper.java
Date Thu, 28 Oct 2004 16:42:37 GMT
luehe       2004/10/28 09:42:37

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardWrapper.java
  Log:
  Prevent NPE when servlet class is not an instance of HttpServlet.
  Return hardcoded set of methods in this case.
  
  Revision  Changes    Path
  1.55      +13 -3     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java
  
  Index: StandardWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- StandardWrapper.java	27 Oct 2004 22:58:17 -0000	1.54
  +++ StandardWrapper.java	28 Oct 2004 16:42:37 -0000	1.55
  @@ -73,6 +73,10 @@
   
       private static org.apache.commons.logging.Log log=
           org.apache.commons.logging.LogFactory.getLog( StandardWrapper.class );
  +
  +    private static final String[] DEFAULT_SERVLET_METHODS = new String[] {
  +                                                    "GET", "HEAD", "POST" };
  +
       // ----------------------------------------------------------- Constructors
   
   
  @@ -563,12 +567,18 @@
        * servlet
        */
       public String[] getServletMethods() throws ServletException {
  -	
  +
  +        Class servletClazz = loadServlet().getClass();
  +        if (!javax.servlet.http.HttpServlet.class.isAssignableFrom(
  +                                                        servletClazz)) {
  +            return DEFAULT_SERVLET_METHODS;
  +        }
  +
           HashSet allow = new HashSet();
           allow.add("TRACE");
           allow.add("OPTIONS");
   	
  -        Method[] methods = getAllDeclaredMethods(loadServlet().getClass());
  +        Method[] methods = getAllDeclaredMethods(servletClazz);
           for (int i=0; methods != null && i<methods.length; i++) {
               Method m = methods[i];
   	    
  
  
  

---------------------------------------------------------------------
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