Index: lucene/core/src/test/org/apache/lucene/util/TestIntsRef.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/util/TestIntsRef.java	(revision 1465953)
+++ lucene/core/src/test/org/apache/lucene/util/TestIntsRef.java	(working copy)
@@ -37,4 +37,14 @@
     
     assertFalse(i.equals(i2));
   }
+  
+  public void testHashcodeZeroFilled() {
+    final int[] array1 = new int[] { 0 };
+    final int[] array2 = new int[] { 0, 0 };
+
+    final IntsRef ints1 = new IntsRef(array1, 0, array1.length);
+    final IntsRef ints2 = new IntsRef(array2, 0, array2.length);
+
+    assertTrue("IntsRef hashcode must be different", ints1.hashCode() != ints2.hashCode());
+  }
 }
Index: lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java	(revision 1465953)
+++ lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java	(working copy)
@@ -169,4 +169,15 @@
       // expected exception
     }
   }
+  
+  public void testHashcodeZeroFilled() {
+    final char[] array1 = new char[] { 0 };
+    final char[] array2 = new char[] { 0, 0 };
+
+    final CharsRef chars1 = new CharsRef(array1, 0, array1.length);
+    final CharsRef chars2 = new CharsRef(array2, 0, array2.length);
+
+    assertTrue("CharsRef hashcode must be different", chars1.hashCode() != chars2.hashCode());
+  }
+  
 }
Index: lucene/core/src/test/org/apache/lucene/util/TestBytesRef.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/util/TestBytesRef.java	(revision 1465953)
+++ lucene/core/src/test/org/apache/lucene/util/TestBytesRef.java	(working copy)
@@ -64,4 +64,15 @@
     b.copyBytes(new BytesRef("bcde"));
     assertEquals("bcde", b.utf8ToString());
   }
+  
+  public void testHashcodeZeroFilled() {
+    final byte[] array1 = new byte[] { 0 };
+    final byte[] array2 = new byte[] { 0, 0 };
+
+    final BytesRef bytes1 = new BytesRef(array1, 0, array1.length);
+    final BytesRef bytes2 = new BytesRef(array2, 0, array2.length);
+
+    assertTrue("BytesRef hashcode must be different", bytes1.hashCode() != bytes2.hashCode());
+  }
+  
 }
Index: lucene/core/src/java/org/apache/lucene/util/CharsRef.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/util/CharsRef.java	(revision 1465953)
+++ lucene/core/src/java/org/apache/lucene/util/CharsRef.java	(working copy)
@@ -79,9 +79,14 @@
   @Override
   public int hashCode() {
     final int prime = 31;
-    int result = 0;
+    
+    if (chars == null) {
+      return 0;
+    }
+  
+    int result = 1;
     final int end = offset + length;
-    for (int i = offset; i < end; i++) {
+    for(int i = offset; i < end; i++) {
       result = prime * result + chars[i];
     }
     return result;
Index: lucene/core/src/java/org/apache/lucene/util/IntsRef.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/util/IntsRef.java	(revision 1465953)
+++ lucene/core/src/java/org/apache/lucene/util/IntsRef.java	(working copy)
@@ -64,7 +64,12 @@
   @Override
   public int hashCode() {
     final int prime = 31;
-    int result = 0;
+    
+    if (ints == null) {
+      return 0;
+    }
+  
+    int result = 1;
     final int end = offset + length;
     for(int i = offset; i < end; i++) {
       result = prime * result + ints[i];
Index: lucene/core/src/java/org/apache/lucene/util/BytesRef.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/util/BytesRef.java	(revision 1465953)
+++ lucene/core/src/java/org/apache/lucene/util/BytesRef.java	(working copy)
@@ -136,12 +136,18 @@
    */
   @Override
   public int hashCode() {
-    int hash = 0;
+    final int prime = 31;
+    
+    if (bytes == null) {
+      return 0;
+    }
+  
+    int result = 1;
     final int end = offset + length;
-    for(int i=offset;i<end;i++) {
-      hash = 31 * hash + bytes[i];
+    for(int i = offset; i < end; i++) {
+      result = prime * result + bytes[i];
     }
-    return hash;
+    return result;
   }
 
   @Override
