commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Lubke <Ryan.Lu...@Sun.COM>
Subject [Fwd: [HttpClient][PATCH] Fix for NPE in PutMethod due to new StatusLine changes]
Date Thu, 05 Sep 2002 03:57:43 GMT
Actually the original patch is incorrect.  Use the attached patch
instead.

If getStatusLine is null, return false, otherwise continue with the rest
of the method body.



-----Forwarded Message-----

From: Ryan Lubke <Ryan.Lubke@Sun.COM>
To: commons-dev@jakarta.apache.org
Subject: [HttpClient][PATCH] Fix for NPE in PutMethod due to new StatusLine changes
Date: 04 Sep 2002 23:50:00 -0400

Had to add an additional check to make sure StatusLine returned from
getStatusLine was not null before attempting to access the status-code.

Unit tests using the PutMethod now pass.

Also a minor update to the log output within HttpMethodBase.


----


Index: HttpMethodBase.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.57
diff -u -r1.57 HttpMethodBase.java
--- HttpMethodBase.java	5 Sep 2002 03:37:55 -0000	1.57
+++ HttpMethodBase.java	5 Sep 2002 03:52:23 -0000
@@ -2041,7 +2041,7 @@
                 bodySent = writeRequestBody(state, connection);
             } else {
                 log.warn("Received status CONTINUE but he body has already been"
-                    + "sent");
+                    + " sent");
                 // According to RFC 2616 this respose should be ignored
             }
             readResponse(state, connection);
Index: methods/PutMethod.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
retrieving revision 1.13
diff -u -r1.13 PutMethod.java
--- methods/PutMethod.java	8 Aug 2002 21:51:36 -0000	1.13
+++ methods/PutMethod.java	5 Sep 2002 03:52:23 -0000
@@ -248,7 +248,8 @@
     throws IOException, HttpException {
         log.trace("enter PutMethod.writeRequestBody(HttpState, HttpConnection)");
 
-        if(null != getRequestHeader("expect") && getStatusCode() != HttpStatus.SC_CONTINUE)
{
+        if(null != getRequestHeader("expect") && getStatusLine() != null &&
+                getStatusLine().getStatusCode() != HttpStatus.SC_CONTINUE) {
             return false;
         }
         OutputStream out = conn.getRequestOutputStream((isHttp11() && (null == getRequestHeader("Content-Length"))));

----


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


Mime
View raw message