ASF Bugzilla – Attachment 18707 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 DefaultServlet
default_servlet_throwable.diff (text/plain), 7.50 KB, created by
J Ross Nicoll
on 2006-08-12 19:30:26 UTC
(
hide
)
Description:
Patch for DefaultServlet
Filename:
MIME Type:
Creator:
J Ross Nicoll
Created:
2006-08-12 19:30:26 UTC
Size:
7.50 KB
patch
obsolete
>diff --unified=3 -r ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java ./container/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java >--- ../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java 2006-04-14 19:11:44.000000000 +0100 >+++ ./container/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java 2006-08-12 20:05:51.000000000 +0100 >@@ -41,6 +41,7 @@ > import javax.naming.NamingEnumeration; > import javax.naming.NamingException; > import javax.naming.directory.DirContext; >+import javax.servlet.ServletConfig; > import javax.servlet.ServletException; > import javax.servlet.ServletOutputStream; > import javax.servlet.UnavailableException; >@@ -208,61 +209,65 @@ > public void destroy() { > } > >+ private boolean getBooleanInitParameter(final ServletConfig config, >+ final String key, final boolean defaultVal) { >+ boolean booleanValue = defaultVal; >+ final String value = config.getInitParameter(key); >+ >+ if (value != null) { >+ booleanValue = Boolean.getBoolean(value); >+ } >+ return booleanValue; >+ } >+ >+ private int getIntInitParameter(final ServletConfig config, >+ final String key, final int defaultVal) { >+ int intValue = defaultVal; >+ final String value = config.getInitParameter(key); >+ >+ if (value != null) { >+ try { >+ intValue = Integer.parseInt(value); >+ } catch(NumberFormatException e) { >+ intValue = defaultVal; >+ log("DefaultServlet.init: Unable to parse init parameter \"" >+ + key + "\"; expected integer, but found \"" >+ + value + "\"."); >+ } >+ } >+ return intValue; >+ } > > /** > * Initialize this servlet. > */ > public void init() throws ServletException { >+ final String value; > > // 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) { >- ; >+ this.debug = getIntInitParameter(getServletConfig(), "debug", this.debug); >+ this.input = getIntInitParameter(getServletConfig(), "input", this.input); >+ this.listings = getBooleanInitParameter(getServletConfig(), "listings", this.listings); >+ this.readOnly = getBooleanInitParameter(getServletConfig(), "readonly", this.readOnly); >+ this.output = getIntInitParameter(getServletConfig(), "output", this.output); >+ >+ value = getServletConfig().getInitParameter("sendfileSize"); >+ if (value != null) { >+ int temp; >+ try { >+ temp = Integer.parseInt(value) * 1024; >+ this.sendfileSize = temp; >+ } catch(NumberFormatException e) { >+ log("DefaultServlet.init: Unable to parse init parameter \"" >+ + "sendfileSize" + "\"; expected integer, but found \"" >+ + value + "\"."); >+ } > } > >- globalXsltFile = getServletConfig().getInitParameter("globalXsltFile"); >- localXsltFile = getServletConfig().getInitParameter("localXsltFile"); >- readmeFile = getServletConfig().getInitParameter("readmeFile"); >+ this.fileEncoding = getServletConfig().getInitParameter("fileEncoding"); >+ this.globalXsltFile = getServletConfig().getInitParameter("globalXsltFile"); >+ this.localXsltFile = getServletConfig().getInitParameter("localXsltFile"); >+ this.readmeFile = getServletConfig().getInitParameter("readmeFile"); > > // Sanity check on the specified buffer sizes > if (input < 256) >@@ -1454,10 +1459,10 @@ > > return buffer.toString(); > } >- } catch(Throwable e) { >- ; /* Should only be IOException or NamingException >- * can be ignored >- */ >+ } catch(IOException e) { >+ // Ignored >+ } catch(NamingException e) { >+ // Ignored > } > } > >@@ -1478,10 +1483,10 @@ > if (is!=null) > return is; > } >- } catch(Throwable e) { >- ; /* Should only be IOException or NamingException >- * can be ignored >- */ >+ } catch(IOException e) { >+ // Ignored >+ } catch(NamingException e) { >+ // Ignored > } > } > >@@ -1499,14 +1504,14 @@ > fis.read(b); > return new ByteArrayInputStream(b); > } >- } catch(Throwable e) { >+ } catch(IOException e) { > log("This shouldn't happen (?)...", e); > return null; > } finally { > try { > if (fis!=null) > fis.close(); >- } catch(Throwable e){ >+ } catch(IOException e){ > ; > } > } >@@ -1762,7 +1767,7 @@ > // Clean up the input stream > try { > istream.close(); >- } catch (Throwable t) { >+ } catch (IOException t) { > ; > } > >@@ -1809,7 +1814,7 @@ > // Clean up the reader > try { > reader.close(); >- } catch (Throwable t) { >+ } catch (IOException t) { > ; > } > >@@ -1844,7 +1849,7 @@ > // Clean up the input stream > try { > istream.close(); >- } catch (Throwable t) { >+ } catch (IOException t) { > ; > } > >@@ -1886,7 +1891,7 @@ > // Clean up the input stream > try { > reader.close(); >- } catch (Throwable t) { >+ } catch (IOException t) { > ; > } > >@@ -1938,7 +1943,7 @@ > > try { > istream.close(); >- } catch (Throwable t) { >+ } catch (IOException t) { > ; > } > >@@ -2001,7 +2006,7 @@ > > try { > reader.close(); >- } catch (Throwable t) { >+ } catch (IOException t) { > ; > }
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