This is an automated email from the ASF dual-hosted git repository.

jmclean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new af79aef70d [#9124] Handle negative partNo safely and fix test file 
typo (#9128)
af79aef70d is described below

commit af79aef70d0ab53d231f39029f19746216e3edec
Author: Harsh Mehta <[email protected]>
AuthorDate: Tue Nov 18 04:36:27 2025 +0530

    [#9124] Handle negative partNo safely and fix test file typo (#9128)
    
    Fixed #9124
    
    - Negative partNo values can now be safely handled.
    - Added unit test cases to verify this behavior.
    - Renamed the test file from TestFulllName to TestFullName to fix a
    minor typo.
    
    ---------
    
    Signed-off-by: Harsh Mehta <[email protected]>
---
 .../java/org/apache/gravitino/cli/FullName.java     |  2 +-
 .../cli/{TestFulllName.java => TestFullName.java}   | 21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java 
b/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java
index 8b435856a7..68dc05f505 100644
--- a/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java
+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java
@@ -215,7 +215,7 @@ public class FullName {
       int length = names.length;
       int position = partNo;
 
-      return position <= length;
+      return position > 0 && position <= length;
     }
 
     return false;
diff --git 
a/clients/cli/src/test/java/org/apache/gravitino/cli/TestFulllName.java 
b/clients/cli/src/test/java/org/apache/gravitino/cli/TestFullName.java
similarity index 94%
rename from 
clients/cli/src/test/java/org/apache/gravitino/cli/TestFulllName.java
rename to clients/cli/src/test/java/org/apache/gravitino/cli/TestFullName.java
index c2e54c81d5..f299d6710d 100644
--- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestFulllName.java
+++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestFullName.java
@@ -37,7 +37,7 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-public class TestFulllName {
+public class TestFullName {
 
   private Options options;
   private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
@@ -271,4 +271,23 @@ public class TestFulllName {
     FullName fullName = new FullName(commandLine);
     assertEquals(4, fullName.getLevel());
   }
+
+  @Test
+  void testHasNamePartWithNegativeIndex() throws Exception {
+    String[] args = {"--name", "catalog.schema.table.column"};
+    CommandLine commandLine = new DefaultParser().parse(options, args);
+    FullName fullName = new FullName(commandLine);
+
+    assertFalse(fullName.hasNamePart(0));
+
+    assertTrue(fullName.hasNamePart(1));
+    assertTrue(fullName.hasNamePart(2));
+    assertTrue(fullName.hasNamePart(3));
+    assertTrue(fullName.hasNamePart(4));
+
+    assertFalse(fullName.hasNamePart(5));
+
+    assertFalse(fullName.hasNamePart(-1));
+    assertFalse(fullName.hasNamePart(-10));
+  }
 }

Reply via email to