hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1043664 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/cookie/BasicClientCookie2.java test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
Date Wed, 08 Dec 2010 20:37:53 GMT
Author: sebb
Date: Wed Dec  8 20:37:53 2010
New Revision: 1043664

URL: http://svn.apache.org/viewvc?rev=1043664&view=rev
Log:
HTTPCLIENT-1031 Cannot clone BasicClientCookie2 without specified ports

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java?rev=1043664&r1=1043663&r2=1043664&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java
Wed Dec  8 20:37:53 2010
@@ -93,7 +93,9 @@ public class BasicClientCookie2 extends 
     @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;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java?rev=1043664&r1=1043663&r2=1043664&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
Wed Dec  8 20:37:53 2010
@@ -72,6 +72,21 @@ public class TestBasicClientCookie2 {
     }
 
     @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");
         orig.setDomain("domain");



Mime
View raw message