Details
-
Bug
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
1.13
-
None
Description
The MurmurHash3.IncrementalHash32 end() method alters the current state of the running hash. Thus if called twice it returns different numbers.
This can be fixed using:
public final int end() { // Allow calling end() again after adding no data to return the same result. int result = hash; // ************ // Note: This fails to apply masking using 0xff to the 3 remaining bytes. // ************ int k1 = 0; switch (unprocessedLength) { case 3: k1 ^= unprocessed[2] << 16; case 2: k1 ^= unprocessed[1] << 8; case 1: k1 ^= unprocessed[0]; // mix functions k1 *= C1_32; k1 = Integer.rotateLeft(k1, R1_32); k1 *= C2_32; result ^= k1; } // finalization result ^= totalLen; return fmix32(result); }