Copilot commented on code in PR #17800:
URL: https://github.com/apache/pinot/pull/17800#discussion_r2879787767


##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/HashUtilsTest.java:
##########
@@ -61,6 +64,19 @@ public void testHashUUID() {
     }
   }
 
+  @Test
+  public void testHashPrimaryKeyWithMd5Disabled() {
+    PrimaryKey primaryKey = new PrimaryKey(new Object[]{"hello world"});
+    try {
+      PinotMd5Mode.setPinotMd5Disabled(true);
+      IllegalStateException exception =
+          expectThrows(IllegalStateException.class, () -> 
HashUtils.hashPrimaryKey(primaryKey, HashFunction.MD5));
+      
assertTrue(exception.getMessage().contains(CommonConstants.CONFIG_OF_PINOT_MD5_DISABLED));
+    } finally {
+      PinotMd5Mode.setPinotMd5Disabled(false);

Review Comment:
   The test changes the global `PinotMd5Mode` state and then resets it to 
`false` unconditionally. For better test isolation (and to support running the 
suite with `-Dpinot.md5.disabled=true`), capture the original 
`PinotMd5Mode.isPinotMd5Disabled()` value and restore it in `finally` instead 
of always forcing `false`.
   ```suggestion
       boolean originalMd5Disabled = PinotMd5Mode.isPinotMd5Disabled();
       try {
         PinotMd5Mode.setPinotMd5Disabled(true);
         IllegalStateException exception =
             expectThrows(IllegalStateException.class, () -> 
HashUtils.hashPrimaryKey(primaryKey, HashFunction.MD5));
         
assertTrue(exception.getMessage().contains(CommonConstants.CONFIG_OF_PINOT_MD5_DISABLED));
       } finally {
         PinotMd5Mode.setPinotMd5Disabled(originalMd5Disabled);
   ```



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