Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/133193.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 133193
summary: Fix offset handling in Murmur3Hasher
area: Infra/Core
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void update(byte[] inputBytes, int offset, int length) {
System.arraycopy(inputBytes, offset + numBytesToHash, remainder, 0, remainderLength);
}
} else {
System.arraycopy(inputBytes, 0, remainder, remainderLength, length);
System.arraycopy(inputBytes, offset, remainder, remainderLength, length);
remainderLength += length;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ private static void assertHash(long lower, long upper, String inputString, long
expected.h2 = upper;

byte[] bytes = inputString.getBytes(StandardCharsets.UTF_8);
int padding = randomInt(8);
int offset = randomInt(padding);
byte[] paddedBytes = new byte[bytes.length + padding];
System.arraycopy(bytes, 0, paddedBytes, offset, bytes.length);
Murmur3Hasher mh = new Murmur3Hasher(seed);
mh.update(bytes);
mh.update(paddedBytes, offset, bytes.length);
MurmurHash3.Hash128 actual = mh.digestHash();
assertHash(expected, actual);
}
Expand Down