hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1523642 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java
Date Mon, 16 Sep 2013 13:29:26 GMT
Author: olegk
Date: Mon Sep 16 13:29:25 2013
New Revision: 1523642

URL: http://svn.apache.org/r1523642
Log:
HTTPCLIENT-1399: fixed NPE in RequestBuilder

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1523642&r1=1523641&r2=1523642&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Mon Sep 16 13:29:25 2013
@@ -1,3 +1,12 @@
+Changes since 4.3
+-------------------
+
+* [HTTPCLIENT-1399] Fixed NPE in RequestBuilder.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+
+
+
 Release 4.3 Final
 -------------------
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java?rev=1523642&r1=1523641&r2=1523642&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
Mon Sep 16 13:29:25 2013
@@ -226,7 +226,7 @@ public class RequestBuilder {
     }
 
     public RequestBuilder setHeader(final Header header) {
-        if (headergroup != null) {
+        if (headergroup == null) {
             headergroup = new HeaderGroup();
         }
         this.headergroup.updateHeader(header);
@@ -234,7 +234,7 @@ public class RequestBuilder {
     }
 
     public RequestBuilder setHeader(final String name, final String value) {
-        if (headergroup != null) {
+        if (headergroup == null) {
             headergroup = new HeaderGroup();
         }
         this.headergroup.updateHeader(new BasicHeader(name, value));

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java?rev=1523642&r1=1523641&r2=1523642&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java
Mon Sep 16 13:29:25 2013
@@ -195,6 +195,11 @@ public class TestRequestBuilder {
         Assert.assertEquals(0, builder.getHeaders("header1").length);
         Assert.assertSame(null, builder.getEntity());
         Assert.assertSame(null, builder.getConfig());
+
+        builder.setHeader(h2)
+            .setHeader("header1", "a-lot-more-stuff");
+        Assert.assertSame("a-lot-more-stuff", builder.getLastHeader("header1").getValue());
+        Assert.assertEquals(1, builder.getHeaders("header1").length);
     }
 
     @Test(expected=IllegalArgumentException.class)



Mime
View raw message