Claudenw commented on a change in pull request #27: Murmur3fix
URL: https://github.com/apache/commons-codec/pull/27#discussion_r341862722
 
 

 ##########
 File path: src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
 ##########
 @@ -602,15 +613,19 @@ public final void add(final byte[] data, int offset, 
final int length) {
                        System.arraycopy(data, offset + consumed, tail, 0, 
tailLen);
                }
 
+               /*
+                * The original algorithm uses unsigned bytes.
+         * We have to mask to match the behavior of the unsigned bytes and 
prevent sign extension.
+         */
                public final int end() {
                        int k1 = 0;
                        switch (tailLen) {
                        case 3:
-                               k1 ^= tail[2] << 16;
+                               k1 ^= (tail[2] & UBYTE_MASK) << 16;
 
 Review comment:
   reverted to ^=

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to