HTTPCLIENT-1399: fixed NPE in RequestBuilder
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1523642 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eff62c7a6e
commit
11536d3d07
|
@ -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
|
||||
-------------------
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue