commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r829285 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/builder/HashCodeBuilder.java test/org/apache/commons/lang/builder/HashCodeBuilderTest.java
Date Sat, 24 Oct 2009 00:04:07 GMT
Author: bayard
Date: Sat Oct 24 00:04:07 2009
New Revision: 829285

URL: http://svn.apache.org/viewvc?rev=829285&view=rev
Log:
Changing the hashCode() method to return toHashCode() per the request in LANG-520

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/HashCodeBuilderTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java?rev=829285&r1=829284&r2=829285&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Sat Oct 24 00:04:07 2009
@@ -969,4 +969,16 @@
         return iTotal;
     }
 
+    /**
+     * <p>
+     * The computed <code>hashCode</code> from toHashCode() is returned due to
the likelyhood 
+     * of bugs in mis-calling toHashCode() and the unlikelyness of it mattering what the
hashCode for 
+     * HashCodeBuilder itself is.
+     * 
+     * @return <code>hashCode</code> based on the fields appended
+     */
+    public int hashCode() {
+        return toHashCode();
+    }
+
 }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/HashCodeBuilderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/HashCodeBuilderTest.java?rev=829285&r1=829284&r2=829285&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/HashCodeBuilderTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/builder/HashCodeBuilderTest.java
Sat Oct 24 00:04:07 2009
@@ -547,4 +547,13 @@
         b.hashCode();
     }
 
+    /**
+     * Ensures LANG-520 remains true
+     */
+    public void testToHashCodeEqualsHashCode() {
+        HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
+        assertEquals("hashCode() is no longer returning the same value as toHashCode() -
see LANG-520", 
+                     hcb.toHashCode(), hcb.hashCode());
+    }
+
 }



Mime
View raw message