HTTPCLIENT-1031 Cannot clone BasicClientCookie2 without specified ports
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1043664 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6e306aa4fd
commit
9475e26293
|
@ -93,7 +93,9 @@ public class BasicClientCookie2 extends BasicClientCookie implements SetCookie2,
|
|||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
BasicClientCookie2 clone = (BasicClientCookie2) super.clone();
|
||||
clone.ports = this.ports.clone();
|
||||
if (this.ports != null) {
|
||||
clone.ports = this.ports.clone();
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,21 @@ public class TestBasicClientCookie2 {
|
|||
Assert.assertEquals(orig.getPorts()[1], clone.getPorts()[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHTTPCLIENT_1031() throws Exception {
|
||||
BasicClientCookie2 orig = new BasicClientCookie2("name", "value");
|
||||
orig.setDomain("domain");
|
||||
orig.setPath("/");
|
||||
orig.setAttribute("attrib", "stuff");
|
||||
BasicClientCookie2 clone = (BasicClientCookie2) orig.clone();
|
||||
Assert.assertEquals(orig.getName(), clone.getName());
|
||||
Assert.assertEquals(orig.getValue(), clone.getValue());
|
||||
Assert.assertEquals(orig.getDomain(), clone.getDomain());
|
||||
Assert.assertEquals(orig.getPath(), clone.getPath());
|
||||
Assert.assertEquals(orig.getAttribute("attrib"), clone.getAttribute("attrib"));
|
||||
Assert.assertNull(clone.getPorts());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() throws Exception {
|
||||
BasicClientCookie2 orig = new BasicClientCookie2("name", "value");
|
||||
|
|
Loading…
Reference in New Issue