nastra commented on code in PR #17393:
URL: https://github.com/apache/iceberg/pull/17393#discussion_r3701896185


##########
core/src/test/java/org/apache/iceberg/deletes/TestBitmapPositionDeleteIndex.java:
##########
@@ -176,6 +177,24 @@ public void testAllContainerTypesIndexSerialization() 
throws Exception {
     validate(index, "all-container-types-position-index.bin");
   }
 
+  @Test
+  public void testDeserializeInvalidCrc() {
+    PositionDeleteIndex index = new BitmapPositionDeleteIndex();
+    index.delete(1L);
+    index.delete(2L);
+    byte[] bytes = index.serialize().array();
+
+    // corrupt the last CRC byte so the computed checksum no longer matches
+    bytes[bytes.length - 1] ^= 0x01;
+
+    DeleteFile dv = mockDV(bytes.length, index.cardinality());
+    Mockito.when(dv.location()).thenReturn("s3://bucket/dv.puffin");
+
+    assertThatThrownBy(() -> PositionDeleteIndex.deserialize(bytes, dv))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageContaining("Invalid CRC for deletion vector 
s3://bucket/dv.puffin");

Review Comment:
   the CRC should be deterministic, can we include it in the message and have 
only a `hasMessage(..)` check instead of just checking part of the message



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to