You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Paul Speed <pa...@objectsciences.com> on 2002/02/20 21:01:38 UTC
Re: cvs commit:
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http
HttpResponseStream.java
Sorry to comment, but I see this one again and again on all kinds of
projects. :)
> - if (servletRequest.getMethod().equals("HEAD"))
> + if ((servletRequest.getMethod() != null)
> + && (servletRequest.getMethod().equals("HEAD"))) {
Almost always better to go ahead and invert the equals:
if ("HEAD".equals(servletRequest.getMethod()))
A simpler idiom to remember and will save the null check. Just a
friendly tip.
-Paul
remm@apache.org wrote:
>
> remm 02/02/20 11:24:38
>
> Modified: catalina/src/share/org/apache/catalina/connector/http
> HttpResponseStream.java
> Log:
> - Fix a NPE which could happen with an invalid request.
>
> Revision Changes Path
> 1.12 +7 -5 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java
>
> Index: HttpResponseStream.java
> ===================================================================
> RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v
> retrieving revision 1.11
> retrieving revision 1.12
> diff -u -r1.11 -r1.12
> --- HttpResponseStream.java 27 Nov 2001 16:22:47 -0000 1.11
> +++ HttpResponseStream.java 20 Feb 2002 19:24:38 -0000 1.12
> @@ -1,7 +1,7 @@
> /*
> - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v 1.11 2001/11/27 16:22:47 remm Exp $
> - * $Revision: 1.11 $
> - * $Date: 2001/11/27 16:22:47 $
> + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v 1.12 2002/02/20 19:24:38 remm Exp $
> + * $Revision: 1.12 $
> + * $Date: 2002/02/20 19:24:38 $
> *
> * ====================================================================
> *
> @@ -250,10 +250,12 @@
> protected void checkHead(HttpResponseImpl response) {
> HttpServletRequest servletRequest =
> (HttpServletRequest) response.getRequest();
> - if (servletRequest.getMethod().equals("HEAD"))
> + if ((servletRequest.getMethod() != null)
> + && (servletRequest.getMethod().equals("HEAD"))) {
> writeContent = false;
> - else
> + } else {
> writeContent = true;
> + }
> }
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>