Update ZipString to deal with reads that do not return all data
Refine the logic in `ZipString.hash` and `ZipString.compare` to deal with the fact a read operation may not return all available bytes. Fixes gh-38751
This commit is contained in:
@@ -86,7 +86,10 @@ class ZipStringTests {
|
||||
case DATA_BLOCK -> {
|
||||
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(source.getBytes(StandardCharsets.UTF_8));
|
||||
assertThat(ZipString.hash(null, dataBlock, 0, (int) dataBlock.size(), addEndSlash)).isEqualTo(expected);
|
||||
|
||||
}
|
||||
case SINGLE_BYTE_READ_DATA_BLOCK -> {
|
||||
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(source.getBytes(StandardCharsets.UTF_8), 1);
|
||||
assertThat(ZipString.hash(null, dataBlock, 0, (int) dataBlock.size(), addEndSlash)).isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,7 +190,7 @@ class ZipStringTests {
|
||||
|
||||
enum HashSourceType {
|
||||
|
||||
STRING, CHAR_SEQUENCE, DATA_BLOCK
|
||||
STRING, CHAR_SEQUENCE, DATA_BLOCK, SINGLE_BYTE_READ_DATA_BLOCK
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user