hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maarten Coene" <MacBelg...@toughguy.net>
Subject [PATCH] Fix for NullPointerException in HttpMethodBase
Date Sun, 29 Dec 2002 23:15:33 GMT
Hi,

I get a NullPointerException if I construct a HttpMethod with an query uri.
Here is a patch to fix this.

I've also included a unit test for this bug (see attachment).

regards,
Maarten Coene


cvs diff -u HttpMethodBase.java
Index: HttpMethodBase.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpc
lient/HttpMethodBase.java,v
retrieving revision 1.93
diff -u -r1.93 HttpMethodBase.java
--- HttpMethodBase.java 20 Dec 2002 09:22:07 -0000 1.93
+++ HttpMethodBase.java 29 Dec 2002 23:06:12 -0000
@@ -302,7 +302,7 @@
             if (pa < 0) { //its just a path
                 setPath(uri);
             } else { //its a path with a query
-                setPath(path.substring(0, pa));
+                setPath(uri.substring(0, pa));
                 setQueryString(uri.substring(pa+1, uri.length()));
             }
         }


cvs diff -u TestNoHost.java
Index: TestNoHost.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpc
lient/TestNoHost.java,v
retrieving revision 1.16
diff -u -r1.16 TestNoHost.java
--- TestNoHost.java 3 Dec 2002 15:28:18 -0000 1.16
+++ TestNoHost.java 29 Dec 2002 23:13:37 -0000
@@ -101,6 +101,7 @@
         suite.addTest(TestStreams.suite());
         suite.addTest(TestStatusLine.suite());
         suite.addTest(TestPartsNoHost.suite());
+        suite.addTest(TestHttpMethodBase.suite());
         return suite;
     }



Mime
View raw message