hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1637960 - in /httpcomponents/httpcore/trunk/httpcore/src: main/java/org/apache/http/message/ test/java/org/apache/http/message/
Date Mon, 10 Nov 2014 19:41:10 GMT
Author: olegk
Date: Mon Nov 10 19:41:09 2014
New Revision: 1637960

URL: http://svn.apache.org/r1637960
Log:
Removed custom #hashCode and #equals methods that do not correctly reflect object identity

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java?rev=1637960&r1=1637959&r2=1637960&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
Mon Nov 10 19:41:09 2014
@@ -31,7 +31,6 @@ import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
 
 /**
  * Basic implementation of {@link HeaderElement}
@@ -117,32 +116,6 @@ public class BasicHeaderElement implemen
     }
 
     @Override
-    public boolean equals(final Object object) {
-        if (this == object) {
-            return true;
-        }
-        if (object instanceof HeaderElement) {
-            final BasicHeaderElement that = (BasicHeaderElement) object;
-            return this.name.equals(that.name)
-                && LangUtils.equals(this.value, that.value)
-                && LangUtils.equals(this.parameters, that.parameters);
-        } else {
-            return false;
-        }
-    }
-
-    @Override
-    public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.name);
-        hash = LangUtils.hashCode(hash, this.value);
-        for (final NameValuePair parameter : this.parameters) {
-            hash = LangUtils.hashCode(hash, parameter);
-        }
-        return hash;
-    }
-
-    @Override
     public String toString() {
         final StringBuilder buffer = new StringBuilder();
         buffer.append(this.name);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java?rev=1637960&r1=1637959&r2=1637960&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java
Mon Nov 10 19:41:09 2014
@@ -32,7 +32,6 @@ import java.io.Serializable;
 import org.apache.http.NameValuePair;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
 
 /**
  * Basic implementation of {@link NameValuePair}.
@@ -84,25 +83,4 @@ public class BasicNameValuePair implemen
         return buffer.toString();
     }
 
-    @Override
-    public boolean equals(final Object object) {
-        if (this == object) {
-            return true;
-        }
-        if (object instanceof NameValuePair) {
-            final BasicNameValuePair that = (BasicNameValuePair) object;
-            return this.name.equals(that.name)
-                  && LangUtils.equals(this.value, that.value);
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.name);
-        hash = LangUtils.hashCode(hash, this.value);
-        return hash;
-    }
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java?rev=1637960&r1=1637959&r2=1637960&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java
Mon Nov 10 19:41:09 2014
@@ -90,61 +90,6 @@ public class TestHeaderElement {
     }
 
     @Test
-    public void testHashCode() {
-        final HeaderElement element1 = new BasicHeaderElement("name", "value",
-                new NameValuePair[] {
-                    new BasicNameValuePair("param1", "value1"),
-                    new BasicNameValuePair("param2", "value2")
-                } );
-        final HeaderElement element2 = new BasicHeaderElement("name", "value",
-                new NameValuePair[] {
-                    new BasicNameValuePair("param2", "value2"),
-                    new BasicNameValuePair("param1", "value1")
-                } );
-        final HeaderElement element3 = new BasicHeaderElement("name", "value");
-        final HeaderElement element4 = new BasicHeaderElement("name", "value");
-        final HeaderElement element5 = new BasicHeaderElement("name", "value",
-                new NameValuePair[] {
-                    new BasicNameValuePair("param1", "value1"),
-                    new BasicNameValuePair("param2", "value2")
-                } );
-        Assert.assertTrue(element1.hashCode() != element2.hashCode());
-        Assert.assertTrue(element1.hashCode() != element3.hashCode());
-        Assert.assertTrue(element2.hashCode() != element3.hashCode());
-        Assert.assertTrue(element3.hashCode() == element4.hashCode());
-        Assert.assertTrue(element1.hashCode() == element5.hashCode());
-    }
-
-    @Test
-    public void testEquals() {
-        final HeaderElement element1 = new BasicHeaderElement("name", "value",
-                new NameValuePair[] {
-                    new BasicNameValuePair("param1", "value1"),
-                    new BasicNameValuePair("param2", "value2")
-                } );
-        final HeaderElement element2 = new BasicHeaderElement("name", "value",
-                new NameValuePair[] {
-                    new BasicNameValuePair("param2", "value2"),
-                    new BasicNameValuePair("param1", "value1")
-                } );
-        final HeaderElement element3 = new BasicHeaderElement("name", "value");
-        final HeaderElement element4 = new BasicHeaderElement("name", "value");
-        final HeaderElement element5 = new BasicHeaderElement("name", "value",
-                new NameValuePair[] {
-                    new BasicNameValuePair("param1", "value1"),
-                    new BasicNameValuePair("param2", "value2")
-                } );
-        Assert.assertTrue(element1.equals(element1));
-        Assert.assertTrue(!element1.equals(element2));
-        Assert.assertTrue(!element1.equals(element3));
-        Assert.assertTrue(!element2.equals(element3));
-        Assert.assertTrue(element3.equals(element4));
-        Assert.assertTrue(element1.equals(element5));
-        Assert.assertFalse(element1.equals(null));
-        Assert.assertFalse(element1.equals("name = value; param1 = value1; param2 = value2"));
-    }
-
-    @Test
     public void testToString() {
         final BasicHeaderElement element = new BasicHeaderElement("name", "value",
                 new NameValuePair[] {

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java?rev=1637960&r1=1637959&r2=1637960&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java
Mon Nov 10 19:41:09 2014
@@ -55,28 +55,6 @@ public class TestNameValuePair {
     }
 
     @Test
-    public void testHashCode() {
-        final NameValuePair param1 = new BasicNameValuePair("name1", "value1");
-        final NameValuePair param2 = new BasicNameValuePair("name2", "value2");
-        final NameValuePair param3 = new BasicNameValuePair("name1", "value1");
-        Assert.assertTrue(param1.hashCode() != param2.hashCode());
-        Assert.assertTrue(param1.hashCode() == param3.hashCode());
-    }
-
-    @Test
-    public void testEquals() {
-        final NameValuePair param1 = new BasicNameValuePair("name1", "value1");
-        final NameValuePair param2 = new BasicNameValuePair("name2", "value2");
-        final NameValuePair param3 = new BasicNameValuePair("name1", "value1");
-        Assert.assertFalse(param1.equals(param2));
-        Assert.assertFalse(param1.equals(null));
-        Assert.assertFalse(param1.equals("name1 = value1"));
-        Assert.assertTrue(param1.equals(param1));
-        Assert.assertTrue(param2.equals(param2));
-        Assert.assertTrue(param1.equals(param3));
-    }
-
-    @Test
     public void testToString() {
         final NameValuePair param1 = new BasicNameValuePair("name1", "value1");
         Assert.assertEquals("name1=value1", param1.toString());



Mime
View raw message