ASF Bugzilla – Attachment 18706 Details for
Bug 40241
java.lang.Throwable is caught inappropriately
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for SSI filter and servlet
ssi_throwable.diff (text/plain), 10.45 KB, created by
J Ross Nicoll
on 2006-08-12 19:29:01 UTC
(
hide
)
Description:
Patch for SSI filter and servlet
Filename:
MIME Type:
Creator:
J Ross Nicoll
Created:
2006-08-12 19:29:01 UTC
Size:
10.45 KB
patch
obsolete
>diff --unified=3 -r ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/ResponseIncludeWrapper.java ./container/catalina/src/share/org/apache/catalina/ssi/ResponseIncludeWrapper.java >--- ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/ResponseIncludeWrapper.java 2006-04-14 19:11:44.000000000 +0100 >+++ ./container/catalina/src/share/org/apache/catalina/ssi/ResponseIncludeWrapper.java 2006-08-12 19:44:40.000000000 +0100 >@@ -19,6 +19,8 @@ > import java.io.IOException; > import java.io.OutputStreamWriter; > import java.io.PrintWriter; >+import java.text.ParseException; >+import java.util.Date; > > import javax.servlet.ServletContext; > import javax.servlet.ServletOutputStream; >@@ -207,8 +209,11 @@ > String lname = name.toLowerCase(); > if (lname.equals(LAST_MODIFIED)) { > try { >- lastModified = DateTool.rfc1123Format.parse(value).getTime(); >- } catch (Throwable ignore) { } >+ final Date temp = DateTool.rfc1123Format.parse(value); >+ lastModified = temp.getTime(); >+ } catch(ParseException e) { >+ // Ignored >+ } > } else if (lname.equals(CONTENT_TYPE)) { > contentType = value; > } >@@ -227,8 +232,11 @@ > String lname = name.toLowerCase(); > if (lname.equals(LAST_MODIFIED)) { > try { >- lastModified = DateTool.rfc1123Format.parse(value).getTime(); >- } catch (Throwable ignore) { } >+ final Date temp = DateTool.rfc1123Format.parse(value); >+ lastModified = temp.getTime(); >+ } catch(ParseException e) { >+ // Ignored >+ } > } > else if (lname.equals(CONTENT_TYPE)) > { >diff --unified=3 -r ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/SSIFilter.java ./container/catalina/src/share/org/apache/catalina/ssi/SSIFilter.java >--- ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/SSIFilter.java 2006-04-14 19:11:44.000000000 +0100 >+++ ./container/catalina/src/share/org/apache/catalina/ssi/SSIFilter.java 2006-08-12 19:44:40.000000000 +0100 >@@ -21,6 +21,7 @@ > import java.io.Reader; > import java.io.Writer; > import java.util.regex.Matcher; >+import java.util.regex.PatternSyntaxException; > import java.util.regex.Pattern; > > import javax.servlet.Filter; >@@ -67,41 +68,66 @@ > this.config = config; > > String value = null; >- try { >- value = config.getInitParameter("debug"); >- debug = Integer.parseInt(value); >- } catch (Throwable t) { >- ; >+ >+ value = config.getInitParameter("debug"); >+ if (value != null) { >+ try { >+ debug = Integer.parseInt(value); >+ } catch (NumberFormatException e) { >+ config.getServletContext().log("Invalid format for debug " >+ + "initParam; expected an integer, but found \"" >+ + value + "\"."); >+ debug = 0; >+ } > } >- try { >- value = config.getInitParameter("contentType"); >- contentTypeRegEx = Pattern.compile(value); >- } catch (Throwable t) { >+ >+ value = config.getInitParameter("contentType"); >+ if (value != null) { >+ try { >+ contentTypeRegEx = Pattern.compile(value); >+ } catch (PatternSyntaxException e) { >+ contentTypeRegEx = shtmlRegEx; >+ StringBuffer msg = new StringBuffer(); >+ msg.append("Invalid format for contentType initParam; "); >+ msg.append("expected regular expression; defaulting to \""); >+ msg.append(shtmlRegEx.pattern()); >+ msg.append("\"."); >+ config.getServletContext().log(msg.toString()); >+ } >+ } else { > contentTypeRegEx = shtmlRegEx; > StringBuffer msg = new StringBuffer(); >- msg.append("Invalid format or no contentType initParam; "); >- msg.append("expected regular expression; defaulting to "); >+ msg.append("No contentType initParam; "); >+ msg.append("expected regular expression; defaulting to \""); > msg.append(shtmlRegEx.pattern()); >+ msg.append("\"."); > config.getServletContext().log(msg.toString()); > } >- try { >- value = config.getInitParameter( >- "isVirtualWebappRelative"); >- isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false; >- } catch (Throwable t) { >- ; >+ >+ value = config.getInitParameter("isVirtualWebappRelative"); >+ if (value != null) { >+ try { >+ isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false; >+ } catch (NumberFormatException e) { >+ config.getServletContext().log("Invalid format for isVirtualWebappRelative " >+ + "initParam; expected an long, but found \"" >+ + value + "\"."); >+ isVirtualWebappRelative = false; >+ } > } >- try { >- value = config.getInitParameter("expires"); >- expires = Long.valueOf(value); >- } catch (NumberFormatException e) { >- expires = null; >- config.getServletContext().log( >- "Invalid format for expires initParam; expected integer (seconds)" >- ); >- } catch (Throwable t) { >- ; >+ >+ value = config.getInitParameter("expires"); >+ if (value != null) { >+ try { >+ expires = Long.valueOf(value); >+ } catch (NumberFormatException e) { >+ expires = null; >+ config.getServletContext().log( >+ "Invalid format for expires initParam; expected integer (seconds)" >+ ); >+ } > } >+ > if (debug > 0) > config.getServletContext().log( > "SSIFilter.init() SSI invoker started with 'debug'=" + debug); >diff --unified=3 -r ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java ./container/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java >--- ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java 2006-04-14 19:11:45.000000000 +0100 >+++ ./container/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java 2006-08-12 19:44:40.000000000 +0100 >@@ -19,6 +19,7 @@ > import java.io.StringWriter; > import java.net.URL; > import java.net.URLConnection; >+import javax.servlet.ServletConfig; > import javax.servlet.ServletContext; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; >@@ -58,48 +59,63 @@ > * if an error occurs > */ > public void init() throws ServletException { >+ final ServletConfig config = getServletConfig(); > 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; >+ >+ value = config.getInitParameter("debug"); >+ if (value != null) { >+ try { >+ debug = Integer.parseInt(value); >+ } catch (NumberFormatException e) { >+ config.getServletContext().log("Invalid format for debug " >+ + "initParam; expected an integer, but found \"" >+ + value + "\"."); >+ debug = 0; >+ } >+ } >+ >+ value = config.getInitParameter("isVirtualWebappRelative"); >+ if (value != null) { >+ try { >+ isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false; >+ } catch (NumberFormatException e) { >+ config.getServletContext().log("Invalid format for isVirtualWebappRelative " >+ + "initParam; expected an long, but found \"" >+ + value + "\"."); >+ isVirtualWebappRelative = false; >+ } >+ } >+ >+ value = config.getInitParameter("expires"); >+ if (value != null) { >+ try { >+ expires = new Long(value); >+ } catch (NumberFormatException e) { >+ config.getServletContext().log("Invalid format for expires " >+ + "initParam; expected a long, but found \"" >+ + value + "\"."); >+ expires = null; > } >- } catch (Throwable t) { >- ; > } >+ >+ value = config.getInitParameter("buffered"); >+ if (value != null) { >+ try { >+ buffered = Integer.parseInt(value) > 0?true:false; >+ } catch (NumberFormatException e) { >+ config.getServletContext().log("Invalid format for buffered " >+ + "initParam; expected 0 or 1, but found \"" >+ + value + "\"."); >+ buffered = false; >+ } >+ } >+ >+ inputEncoding = getServletConfig().getInitParameter("inputEncoding"); >+ value = getServletConfig().getInitParameter("outputEncoding"); >+ if (value != null) { >+ outputEncoding = value; >+ } >+ > if (debug > 0) > log("SSIServlet.init() SSI invoker started with 'debug'=" + debug); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 40241
: 18706 |
18707