tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 8013] - DefaultServlet Throws NumberFormatException
Date Fri, 07 Jun 2002 02:12:55 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8013>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8013

DefaultServlet Throws NumberFormatException





------- Additional Comments From james@carmanconsulting.com  2002-06-07 02:12 -------
I would recommend the following refactorings for the DefaultServlet class...

1.  Use the "extract method" refactoring for each of the "if" checks in the 
checkIfHeaders() method, resulting in the following four new helper methods.

private boolean checkIfMatch(HttpServletRequest request,
                             HttpServletResponse response,
                             ResourceInfo resourceInfo);
private boolean checkIfModifiedSince(HttpServletRequest request,
                                     HttpServletResponse response,
                                     ResourceInfo resourceInfo);
private boolean checkIfNoneMatch(HttpServletRequest request,
                                 HttpServletResponse response,
                                 ResourceInfo resourceInfo);
private boolean checkIfUnmodifiedSince(HttpServletRequest request,
                                       HttpServletResponse response,
                                       ResourceInfo resourceInfo);

Of course, these methods should rely on the HttpServletRequest.getDateHeader() 
method where applicable, rather than performing their own date parsing, using 
the static "formats" array.

2.  The checkIfHeaders() method should contain the following logic...

protected boolean checkIfHeaders(HttpServletRequest request,
                                 HttpServletResponse response,
                                 ResourceInfo resourceInfo)
                                 throws IOException {
  return checkIfMatch(request, response, resourceInfo) &&
         checkIfModifiedSince(request, response, resourceInfo) &&
         checkIfNoneMatch(request, response, resourceInfo) &&
         checkIfUnmodifiedSince(request, response, resourceInfo);
}

3.  The static "formats" array should be removed, as they are not thread-safe.

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


Mime
View raw message