You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2006/09/29 00:00:57 UTC

svn commit: r451035 - in /tomcat/tc6.0.x/trunk/java/org/apache/catalina: servlets/CGIServlet.java servlets/DefaultServlet.java servlets/InvokerServlet.java servlets/WebdavServlet.java ssi/SSIServlet.java

Author: remm
Date: Thu Sep 28 15:00:56 2006
New Revision: 451035

URL: http://svn.apache.org/viewvc?view=rev&rev=451035
Log:
- Exception processing cleanup, as suggested by one guy in the past.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/InvokerServlet.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ssi/SSIServlet.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java?view=diff&rev=451035&r1=451034&r2=451035
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java Thu Sep 28 15:00:56 2006
@@ -294,22 +294,13 @@
         if (servletName.startsWith("org.apache.catalina.INVOKER."))
             throw new UnavailableException
                 ("Cannot invoke CGIServlet through the invoker");
-
-        boolean passShellEnvironment = false;
         
         // Set our properties from the initialization parameters
-        String value = null;
-        try {
-            value = getServletConfig().getInitParameter("debug");
-            debug = Integer.parseInt(value);
-            cgiPathPrefix =
-                getServletConfig().getInitParameter("cgiPathPrefix");
-            value = getServletConfig().getInitParameter("passShellEnvironment");
-            passShellEnvironment = Boolean.valueOf(value).booleanValue();
-        } catch (Throwable t) {
-            //NOOP
-        }
-        log("init: loglevel set to " + debug);
+        if (getServletConfig().getInitParameter("debug") != null)
+            debug = Integer.parseInt(getServletConfig().getInitParameter("debug"));
+        cgiPathPrefix = getServletConfig().getInitParameter("cgiPathPrefix");
+        boolean passShellEnvironment = 
+            Boolean.valueOf(getServletConfig().getInitParameter("passShellEnvironment")).booleanValue();
 
         if (passShellEnvironment) {
             try {
@@ -321,14 +312,12 @@
             }
         }
 
-        value = getServletConfig().getInitParameter("executable");
-        if (value != null) {
-            cgiExecutable = value;
+        if (getServletConfig().getInitParameter("executable") != null) {
+            cgiExecutable = getServletConfig().getInitParameter("executable");
         }
 
-        value = getServletConfig().getInitParameter("parameterEncoding");
-        if (value != null) {
-            parameterEncoding = value;
+        if (getServletConfig().getInitParameter("parameterEncoding") != null) {
+            parameterEncoding = getServletConfig().getInitParameter("parameterEncoding");
         }
 
     }
@@ -602,43 +591,40 @@
         }
  
         if (debug >= 10) {
-            try {
-                ServletOutputStream out = res.getOutputStream();
-                out.println("<HTML><HEAD><TITLE>$Name$</TITLE></HEAD>");
-                out.println("<BODY>$Header$<p>");
-
-                if (cgiEnv.isValid()) {
-                    out.println(cgiEnv.toString());
-                } else {
-                    out.println("<H3>");
-                    out.println("CGI script not found or not specified.");
-                    out.println("</H3>");
-                    out.println("<H4>");
-                    out.println("Check the <b>HttpServletRequest ");
-                    out.println("<a href=\"#pathInfo\">pathInfo</a></b> ");
-                    out.println("property to see if it is what you meant ");
-                    out.println("it to be.  You must specify an existant ");
-                    out.println("and executable file as part of the ");
-                    out.println("path-info.");
-                    out.println("</H4>");
-                    out.println("<H4>");
-                    out.println("For a good discussion of how CGI scripts ");
-                    out.println("work and what their environment variables ");
-                    out.println("mean, please visit the <a ");
-                    out.println("href=\"http://cgi-spec.golux.com\">CGI ");
-                    out.println("Specification page</a>.");
-                    out.println("</H4>");
 
-                }
+            ServletOutputStream out = res.getOutputStream();
+            out.println("<HTML><HEAD><TITLE>$Name$</TITLE></HEAD>");
+            out.println("<BODY>$Header$<p>");
+
+            if (cgiEnv.isValid()) {
+                out.println(cgiEnv.toString());
+            } else {
+                out.println("<H3>");
+                out.println("CGI script not found or not specified.");
+                out.println("</H3>");
+                out.println("<H4>");
+                out.println("Check the <b>HttpServletRequest ");
+                out.println("<a href=\"#pathInfo\">pathInfo</a></b> ");
+                out.println("property to see if it is what you meant ");
+                out.println("it to be.  You must specify an existant ");
+                out.println("and executable file as part of the ");
+                out.println("path-info.");
+                out.println("</H4>");
+                out.println("<H4>");
+                out.println("For a good discussion of how CGI scripts ");
+                out.println("work and what their environment variables ");
+                out.println("mean, please visit the <a ");
+                out.println("href=\"http://cgi-spec.golux.com\">CGI ");
+                out.println("Specification page</a>.");
+                out.println("</H4>");
 
-                printServletEnvironment(out, req, res);
+            }
 
-                out.println("</BODY></HTML>");
+            printServletEnvironment(out, req, res);
 
-            } catch (IOException ignored) {
-            }
+            out.println("</BODY></HTML>");
 
-        } //debugging
+        }
 
 
     } //doGet

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?view=diff&rev=451035&r1=451034&r2=451035
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Thu Sep 28 15:00:56 2006
@@ -49,6 +49,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
@@ -214,51 +215,24 @@
      */
     public void init() throws ServletException {
 
-        // Set our properties from the initialization parameters
-        String value = null;
-        try {
-            value = getServletConfig().getInitParameter("debug");
-            debug = Integer.parseInt(value);
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("input");
-            input = Integer.parseInt(value);
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("listings");
-            listings = (new Boolean(value)).booleanValue();
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("readonly");
-            if (value != null)
-                readOnly = (new Boolean(value)).booleanValue();
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("output");
-            output = Integer.parseInt(value);
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("sendfileSize");
-            sendfileSize = Integer.parseInt(value) * 1024;
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("fileEncoding");
-            fileEncoding = value;
-        } catch (Throwable t) {
-            ;
-        }
+        debug = Integer.parseInt(getServletConfig().getInitParameter("debug"));
+
+        if (getServletConfig().getInitParameter("input") != null)
+            input = Integer.parseInt(getServletConfig().getInitParameter("input"));
+
+        if (getServletConfig().getInitParameter("output") != null)
+            output = Integer.parseInt(getServletConfig().getInitParameter("output"));
+
+        listings = Boolean.parseBoolean(getServletConfig().getInitParameter("listings"));
+
+        if (getServletConfig().getInitParameter("readonly") != null)
+            readOnly = Boolean.parseBoolean(getServletConfig().getInitParameter("readonly"));
+
+        if (getServletConfig().getInitParameter("sendfileSize") != null)
+            sendfileSize = 
+                Integer.parseInt(getServletConfig().getInitParameter("sendfileSize")) * 1024;
+
+        fileEncoding = getServletConfig().getInitParameter("fileEncoding");
 
         globalXsltFile = getServletConfig().getInitParameter("globalXsltFile");
         localXsltFile = getServletConfig().getInitParameter("localXsltFile");
@@ -276,12 +250,8 @@
         }
 
         // Load the proxy dir context.
-        try {
-            resources = (ProxyDirContext) getServletContext()
-                .getAttribute(Globals.RESOURCES_ATTR);
-        } catch(ClassCastException e) {
-            // Failed : Not the right type
-        }
+        resources = (ProxyDirContext) getServletContext()
+            .getAttribute(Globals.RESOURCES_ATTR);
         if (resources == null) {
             try {
                 resources =
@@ -289,8 +259,7 @@
                     .lookup(RESOURCES_JNDI_NAME);
             } catch (NamingException e) {
                 // Failed
-            } catch (ClassCastException e) {
-                // Failed : Not the right type
+                throw new ServletException("No resources", e);
             }
         }
 
@@ -492,6 +461,7 @@
             if (obj instanceof Resource)
                 oldResource = (Resource) obj;
         } catch (NamingException e) {
+            ;
         }
 
         // Copy data in oldRevisionContent to contentFile
@@ -991,7 +961,7 @@
             long headerValueTime = (-1L);
             try {
                 headerValueTime = request.getDateHeader("If-Range");
-            } catch (Exception e) {
+            } catch (IllegalArgumentException e) {
                 ;
             }
 
@@ -1114,8 +1084,9 @@
     /**
      *  Decide which way to render. HTML or XML.
      */
-    protected InputStream render
-        (String contextPath, CacheEntry cacheEntry) {
+    protected InputStream render(String contextPath, CacheEntry cacheEntry)
+        throws IOException, ServletException {
+
         InputStream xsltInputStream =
             findXsltInputStream(cacheEntry.context);
 
@@ -1136,7 +1107,8 @@
      */
     protected InputStream renderXml(String contextPath,
                                     CacheEntry cacheEntry,
-                                    InputStream xsltInputStream) {
+                                    InputStream xsltInputStream)
+        throws IOException, ServletException {
 
         StringBuffer sb = new StringBuffer();
 
@@ -1205,7 +1177,7 @@
 
         } catch (NamingException e) {
             // Something went wrong
-            e.printStackTrace();
+            throw new ServletException("Error accessing resource", e);
         }
 
         sb.append("</entries>");
@@ -1234,9 +1206,8 @@
             transformer.transform(xmlSource, out);
             osWriter.flush();
             return (new ByteArrayInputStream(stream.toByteArray()));
-        } catch (Exception e) {
-            log("directory transform failure: " + e.getMessage());
-            return renderHtml(contextPath, cacheEntry);
+        } catch (TransformerException e) {
+            throw new ServletException("XSL transformer error", e);
         }
     }
 
@@ -1247,8 +1218,8 @@
      * @param contextPath Context path to which our internal paths are
      *  relative
      */
-    protected InputStream renderHtml
-        (String contextPath, CacheEntry cacheEntry) {
+    protected InputStream renderHtml(String contextPath, CacheEntry cacheEntry)
+        throws IOException, ServletException {
 
         String name = cacheEntry.name;
 
@@ -1261,13 +1232,7 @@
 
         // Prepare a writer to a buffered area
         ByteArrayOutputStream stream = new ByteArrayOutputStream();
-        OutputStreamWriter osWriter = null;
-        try {
-            osWriter = new OutputStreamWriter(stream, "UTF8");
-        } catch (Exception e) {
-            // Should never happen
-            osWriter = new OutputStreamWriter(stream);
-        }
+        OutputStreamWriter osWriter = new OutputStreamWriter(stream, "UTF8");
         PrintWriter writer = new PrintWriter(osWriter);
 
         StringBuffer sb = new StringBuffer();
@@ -1386,7 +1351,7 @@
 
         } catch (NamingException e) {
             // Something went wrong
-            e.printStackTrace();
+            throw new ServletException("Error accessing resource", e);
         }
 
         // Render the page footer
@@ -1432,24 +1397,22 @@
     /**
      * Get the readme file as a string.
      */
-    protected String getReadme(DirContext directory) {
-        if (readmeFile!=null) {
+    protected String getReadme(DirContext directory)
+        throws IOException, ServletException {
+
+        if (readmeFile != null) {
             try {
                 Object obj = directory.lookup(readmeFile);
-
-                if (obj!=null && obj instanceof Resource) {
+                if ((obj != null) && (obj instanceof Resource)) {
                     StringWriter buffer = new StringWriter();
-                    InputStream is = ((Resource)obj).streamContent();
+                    InputStream is = ((Resource) obj).streamContent();
                     copyRange(new InputStreamReader(is),
-                              new PrintWriter(buffer));
-
+                            new PrintWriter(buffer));
                     return buffer.toString();
-                 }
-             } catch(Throwable e) {
-                 ; /* Should only be IOException or NamingException
-                    * can be ignored
-                    */
-             }
+                }
+            } catch (NamingException e) {
+                throw new ServletException("Error opening readme resource", e);
+            }
         }
 
         return null;
@@ -1459,21 +1422,20 @@
     /**
      * Return the xsl template inputstream (if possible)
      */
-    protected InputStream findXsltInputStream(DirContext directory) {
+    protected InputStream findXsltInputStream(DirContext directory)
+        throws IOException, ServletException {
 
-        if (localXsltFile!=null) {
+        if (localXsltFile != null) {
             try {
                 Object obj = directory.lookup(localXsltFile);
-                if (obj!=null && obj instanceof Resource) {
-                    InputStream is = ((Resource)obj).streamContent();
-                    if (is!=null)
+                if ((obj != null) && (obj instanceof Resource)) {
+                    InputStream is = ((Resource) obj).streamContent();
+                    if (is != null)
                         return is;
                 }
-             } catch(Throwable e) {
-                 ; /* Should only be IOException or NamingException
-                    * can be ignored
-                    */
-             }
+            } catch (NamingException e) {
+                throw new ServletException("Error opening XSLT resource", e);
+            }
         }
 
         /*  Open and read in file in one fell swoop to reduce chance
@@ -1490,16 +1452,9 @@
                     fis.read(b);
                     return new ByteArrayInputStream(b);
                 }
-            } catch(Throwable e) {
-                log("This shouldn't happen (?)...", e);
-                return null;
             } finally {
-                try {
-                    if (fis!=null)
-                        fis.close();
-                } catch(Throwable e){
-                    ;
-                }
+                if (fis!=null)
+                    fis.close();
             }
         }
 
@@ -1615,7 +1570,7 @@
                     return false;
                 }
             }
-        } catch(IllegalArgumentException illegalArgument) {
+        } catch (IllegalArgumentException illegalArgument) {
             return true;
         }
         return true;
@@ -1751,11 +1706,7 @@
         exception = copyRange(istream, ostream);
 
         // Clean up the input stream
-        try {
-            istream.close();
-        } catch (Throwable t) {
-            ;
-        }
+        istream.close();
 
         // Rethrow any exception that has occurred
         if (exception != null)
@@ -1798,11 +1749,7 @@
         exception = copyRange(reader, writer);
 
         // Clean up the reader
-        try {
-            reader.close();
-        } catch (Throwable t) {
-            ;
-        }
+        reader.close();
 
         // Rethrow any exception that has occurred
         if (exception != null)
@@ -1833,11 +1780,7 @@
         exception = copyRange(istream, ostream, range.start, range.end);
 
         // Clean up the input stream
-        try {
-            istream.close();
-        } catch (Throwable t) {
-            ;
-        }
+        istream.close();
 
         // Rethrow any exception that has occurred
         if (exception != null)
@@ -1875,11 +1818,7 @@
         exception = copyRange(reader, writer, range.start, range.end);
 
         // Clean up the input stream
-        try {
-            reader.close();
-        } catch (Throwable t) {
-            ;
-        }
+        reader.close();
 
         // Rethrow any exception that has occurred
         if (exception != null)
@@ -1927,11 +1866,7 @@
             exception = copyRange(istream, ostream, currentRange.start,
                                   currentRange.end);
 
-            try {
-                istream.close();
-            } catch (Throwable t) {
-                ;
-            }
+            istream.close();
 
         }
 
@@ -1990,11 +1925,7 @@
             exception = copyRange(reader, writer, currentRange.start,
                                   currentRange.end);
 
-            try {
-                reader.close();
-            } catch (Throwable t) {
-                ;
-            }
+            reader.close();
 
         }
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/InvokerServlet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/InvokerServlet.java?view=diff&rev=451035&r1=451034&r2=451035
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/InvokerServlet.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/InvokerServlet.java Thu Sep 28 15:00:56 2006
@@ -182,13 +182,9 @@
                 (sm.getString("invokerServlet.noWrapper"));
 
         // Set our properties from the initialization parameters
-        String value = null;
-        try {
-            value = getServletConfig().getInitParameter("debug");
-            debug = Integer.parseInt(value);
-        } catch (Throwable t) {
-            ;
-        }
+        if (getServletConfig().getInitParameter("debug") != null)
+            debug = Integer.parseInt(getServletConfig().getInitParameter("debug"));
+
         if (debug >= 1)
             log("init: Associated with Context '" + context.getPath() + "'");
 
@@ -264,9 +260,6 @@
         String pathInfo = inPathInfo;
         String servletClass = pathInfo.substring(1);
         int slash = servletClass.indexOf('/');
-        //        if (debug >= 2)
-        //            log("  Calculating with servletClass='" + servletClass +
-        //                "', pathInfo='" + pathInfo + "', slash=" + slash);
         if (slash >= 0) {
             pathInfo = servletClass.substring(slash);
             servletClass = servletClass.substring(0, slash);
@@ -325,15 +318,15 @@
                     wrapper.setServletClass(servletClass);
                     context.addChild(wrapper);
                     context.addServletMapping(pattern, name);
-                } catch (Throwable t) {
+                } catch (Exception e) {
                     log(sm.getString("invokerServlet.cannotCreate",
-                                     inRequestURI), t);
+                                     inRequestURI), e);
                     context.removeServletMapping(pattern);
                     context.removeChild(wrapper);
                     if (included)
                         throw new ServletException
                             (sm.getString("invokerServlet.cannotCreate",
-                                          inRequestURI), t);
+                                          inRequestURI), e);
                     else {
                         response.sendError(HttpServletResponse.SC_NOT_FOUND,
                                            inRequestURI);
@@ -364,8 +357,6 @@
         // Allocate a servlet instance to perform this request
         Servlet instance = null;
         try {
-            //            if (debug >= 2)
-            //                log("  Allocating servlet instance");
             instance = wrapper.allocate();
         } catch (ServletException e) {
             log(sm.getString("invokerServlet.allocate", inRequestURI), e);
@@ -389,12 +380,6 @@
                     (sm.getString("invokerServlet.allocate", inRequestURI),
                      rootCause);
             }
-        } catch (Throwable e) {
-            log(sm.getString("invokerServlet.allocate", inRequestURI), e);
-            context.removeServletMapping(pattern);
-            context.removeChild(wrapper);
-            throw new ServletException
-                (sm.getString("invokerServlet.allocate", inRequestURI), e);
         }
 
         // After loading the wrapper, restore some of the fields when including
@@ -413,82 +398,20 @@
                 request.removeAttribute(Globals.JSP_FILE_ATTR);
             request.setAttribute(Globals.INVOKED_ATTR,
                                  request.getServletPath());
-            //            if (debug >= 2)
-            //                log("  Calling service() method, jspFile=" +
-            //                    jspFile);
             instance.service(wrequest, response);
-            request.removeAttribute(Globals.INVOKED_ATTR);
-            request.removeAttribute(Globals.JSP_FILE_ATTR);
-        } catch (IOException e) {
-            //            if (debug >= 2)
-            //                log("  service() method IOException", e);
-            request.removeAttribute(Globals.INVOKED_ATTR);
-            request.removeAttribute(Globals.JSP_FILE_ATTR);
-            try {
-                wrapper.deallocate(instance);
-            } catch (Throwable f) {
-                ;
-            }
-            throw e;
         } catch (UnavailableException e) {
-            //            if (debug >= 2)
-            //                log("  service() method UnavailableException", e);
             context.removeServletMapping(pattern);
-            request.removeAttribute(Globals.INVOKED_ATTR);
-            request.removeAttribute(Globals.JSP_FILE_ATTR);
-            try {
-                wrapper.deallocate(instance);
-            } catch (Throwable f) {
-                ;
-            }
             throw e;
-        } catch (ServletException e) {
-            //            if (debug >= 2)
-            //                log("  service() method ServletException", e);
-            request.removeAttribute(Globals.INVOKED_ATTR);
-            request.removeAttribute(Globals.JSP_FILE_ATTR);
-            try {
-                wrapper.deallocate(instance);
-            } catch (Throwable f) {
-                ;
-            }
-            throw e;
-        } catch (RuntimeException e) {
-            //            if (debug >= 2)
-            //                log("  service() method RuntimeException", e);
+        } finally {
             request.removeAttribute(Globals.INVOKED_ATTR);
             request.removeAttribute(Globals.JSP_FILE_ATTR);
+            // Deallocate the allocated servlet instance
             try {
                 wrapper.deallocate(instance);
-            } catch (Throwable f) {
-                ;
+            } catch (ServletException e) {
+                log(sm.getString("invokerServlet.deallocate", inRequestURI), e);
+                throw e;
             }
-            throw e;
-        } catch (Throwable e) {
-            //            if (debug >= 2)
-            //                log("  service() method Throwable", e);
-            request.removeAttribute(Globals.INVOKED_ATTR);
-            request.removeAttribute(Globals.JSP_FILE_ATTR);
-            try {
-                wrapper.deallocate(instance);
-            } catch (Throwable f) {
-                ;
-            }
-            throw new ServletException("Invoker service() exception", e);
-        }
-
-        // Deallocate the allocated servlet instance
-        try {
-            //            if (debug >= 2)
-            //                log("  deallocate servlet instance");
-            wrapper.deallocate(instance);
-        } catch (ServletException e) {
-            log(sm.getString("invokerServlet.deallocate", inRequestURI), e);
-            throw e;
-        } catch (Throwable e) {
-            log(sm.getString("invokerServlet.deallocate", inRequestURI), e);
-            throw new ServletException
-                (sm.getString("invokerServlet.deallocate", inRequestURI), e);
         }
 
     }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java?view=diff&rev=451035&r1=451034&r2=451035
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java Thu Sep 28 15:00:56 2006
@@ -213,15 +213,8 @@
 
         super.init();
 
-        String value = null;
-        try {
-            value = getServletConfig().getInitParameter("secret");
-            if (value != null)
-                secret = value;
-        } catch (Throwable t) {
-            ;
-        }
-
+        if (getServletConfig().getInitParameter("secret") != null)
+            secret = getServletConfig().getInitParameter("secret");
 
         // Load the MD5 helper used to calculate signatures.
         try {
@@ -415,9 +408,10 @@
                     break;
                 }
             }
-        } catch(Exception e) {
+        } catch (SAXException e) {
+            // Most likely there was no content : we use the defaults.
+        } catch (IOException e) {
             // Most likely there was no content : we use the defaults.
-            // TODO : Enhance that !
         }
 
         if (type == FIND_BY_PROPERTY) {
@@ -862,7 +856,9 @@
             // Get the root element of the document
             Element rootElement = document.getDocumentElement();
             lockInfoNode = rootElement;
-        } catch(Exception e) {
+        } catch (IOException e) {
+            lockRequestType = LOCK_REFRESH;
+        } catch (SAXException e) {
             lockRequestType = LOCK_REFRESH;
         }
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ssi/SSIServlet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ssi/SSIServlet.java?view=diff&rev=451035&r1=451034&r2=451035
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ssi/SSIServlet.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ssi/SSIServlet.java Thu Sep 28 15:00:56 2006
@@ -58,50 +58,26 @@
      *                if an error occurs
      */
     public void init() throws ServletException {
-        String value = null;
-        try {
-            value = getServletConfig().getInitParameter("debug");
-            debug = Integer.parseInt(value);
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter(
-                    "isVirtualWebappRelative");
-            isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false;
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("expires");
-            expires = Long.valueOf(value);
-        } catch (NumberFormatException e) {
-            expires = null;
-            log("Invalid format for expires initParam; expected integer (seconds)");
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("buffered");
-            buffered = Integer.parseInt(value) > 0?true:false;
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            inputEncoding = getServletConfig().getInitParameter("inputEncoding");
-        } catch (Throwable t) {
-            ;
-        }
-        try {
-            value = getServletConfig().getInitParameter("outputEncoding");
-            if (value != null) {
-                outputEncoding = value;
-            }
-        } catch (Throwable t) {
-            ;
-        }
+        
+        if (getServletConfig().getInitParameter("debug") != null)
+            debug = Integer.parseInt(getServletConfig().getInitParameter("debug"));
+        
+        isVirtualWebappRelative = 
+            Boolean.parseBoolean(getServletConfig().getInitParameter("isVirtualWebappRelative"));
+        
+        if (getServletConfig().getInitParameter("expires") != null)
+            expires = Long.valueOf(getServletConfig().getInitParameter("expires"));
+        
+        buffered = Boolean.parseBoolean(getServletConfig().getInitParameter("buffered"));
+        
+        inputEncoding = getServletConfig().getInitParameter("inputEncoding");
+        
+        if (getServletConfig().getInitParameter("outputEncoding") != null)
+            outputEncoding = getServletConfig().getInitParameter("outputEncoding");
+        
         if (debug > 0)
             log("SSIServlet.init() SSI invoker started with 'debug'=" + debug);
+
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org