Copilot commented on code in PR #13231:
URL: https://github.com/apache/gravitino/pull/13231#discussion_r4026165833


##########
api/src/main/java/org/apache/gravitino/rel/indexes/Indexes.java:
##########
@@ -155,8 +155,13 @@ private IndexImpl(
         IndexType indexType, String name, String[][] fieldNames, Map<String, 
String> properties) {
       this.indexType = indexType;
       this.name = name;
-      this.fieldNames = fieldNames;
-      this.properties = properties == null ? ImmutableMap.of() : properties;
+      // Deep-copy the caller's arrays and snapshot the map so later external 
mutations of the
+      // caller's inputs cannot change the built index.
+      this.fieldNames =
+          fieldNames == null
+              ? null
+              : 
Arrays.stream(fieldNames).map(String[]::clone).toArray(String[][]::new);

Review Comment:
   `String[]::clone` is invoked unconditionally, so `Indexes.of(..., new 
String[][] {null}, ...)` now throws `NullPointerException`. The previous 
implementation accepted this value, and `Arrays.deepEquals`/`deepHashCode` are 
null-safe, so this is an unintended compatibility regression. Preserve null 
rows while cloning (for example, `row == null ? null : row.clone()`).



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

Reply via email to