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 [EMAIL PROTECTED]  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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to