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


##########
core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java:
##########
@@ -82,7 +82,9 @@ public NameIdentifier[] listCatalogs(Namespace namespace) 
throws NoSuchMetalakeE
     eventBus.dispatchEvent(new 
ListCatalogPreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       NameIdentifier[] nameIdentifiers = dispatcher.listCatalogs(namespace);
-      eventBus.dispatchEvent(new 
ListCatalogEvent(PrincipalUtils.getCurrentUserName(), namespace));
+      eventBus.dispatchEvent(
+          new ListCatalogEvent(
+              PrincipalUtils.getCurrentUserName(), namespace, 
nameIdentifiers.length));
       return nameIdentifiers;

Review Comment:
   `dispatcher.listCatalogs(namespace)` is assumed non-null, but 
`nameIdentifiers.length` will throw an NPE if null is returned (older tests 
mocked null). Consider guarding the count calculation (null => -1/0) before 
emitting `ListCatalogEvent`, or enforce/document a non-null return contract for 
list operations.



##########
core/src/main/java/org/apache/gravitino/listener/TableEventDispatcher.java:
##########
@@ -83,7 +83,9 @@ public NameIdentifier[] listTables(Namespace namespace) 
throws NoSuchSchemaExcep
     eventBus.dispatchEvent(new 
ListTablePreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       NameIdentifier[] nameIdentifiers = dispatcher.listTables(namespace);
-      eventBus.dispatchEvent(new 
ListTableEvent(PrincipalUtils.getCurrentUserName(), namespace));
+      eventBus.dispatchEvent(
+          new ListTableEvent(
+              PrincipalUtils.getCurrentUserName(), namespace, 
nameIdentifiers.length));

Review Comment:
   `dispatcher.listTables(namespace)` is assumed to return a non-null array, 
but this method now dereferences `nameIdentifiers.length`. If any dispatcher 
implementation returns null (older tests mocked null), this will throw an NPE 
and break the list operation. Consider guarding (e.g., treat null as “count not 
captured” using -1 or as 0) before constructing `ListTableEvent`, or 
enforce/document a strict non-null contract for list methods.
   



##########
core/src/main/java/org/apache/gravitino/listener/FunctionEventDispatcher.java:
##########
@@ -77,7 +77,7 @@ public NameIdentifier[] listFunctions(Namespace namespace) 
throws NoSuchSchemaEx
     eventBus.dispatchEvent(new ListFunctionPreEvent(user, namespace));
     try {
       NameIdentifier[] nameIdentifiers = dispatcher.listFunctions(namespace);
-      eventBus.dispatchEvent(new ListFunctionEvent(user, namespace));
+      eventBus.dispatchEvent(new ListFunctionEvent(user, namespace, 
nameIdentifiers.length));

Review Comment:
   `dispatcher.listFunctions(namespace)` is assumed non-null, but 
`nameIdentifiers.length` will throw an NPE if a dispatcher returns null (older 
tests mocked null). Consider guarding the count derivation (null => -1/0) 
before emitting `ListFunctionEvent`, or enforce/document that list methods 
return empty arrays rather than null.
   



##########
core/src/main/java/org/apache/gravitino/listener/PartitionEventDispatcher.java:
##########
@@ -148,7 +150,8 @@ public String[] listPartitionNames(NameIdentifier ident) {
     try {
       String[] listPartitionNames = dispatcher.listPartitionNames(ident);
       eventBus.dispatchEvent(
-          new ListPartitionNamesEvent(PrincipalUtils.getCurrentUserName(), 
ident));
+          new ListPartitionNamesEvent(
+              PrincipalUtils.getCurrentUserName(), ident, 
listPartitionNames.length));
       return listPartitionNames;

Review Comment:
   `dispatcher.listPartitionNames(ident)` is assumed non-null, but 
`listPartitionNames.length` will NPE if null is returned (older tests mocked 
null). Consider guarding the count derivation (null => -1/0) before emitting 
`ListPartitionNamesEvent`, or enforce/document that list methods return empty 
arrays rather than null.



##########
core/src/main/java/org/apache/gravitino/listener/TopicEventDispatcher.java:
##########
@@ -106,7 +106,9 @@ public NameIdentifier[] listTopics(Namespace namespace) 
throws NoSuchTopicExcept
     eventBus.dispatchEvent(new 
ListTopicPreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       NameIdentifier[] nameIdentifiers = dispatcher.listTopics(namespace);
-      eventBus.dispatchEvent(new 
ListTopicEvent(PrincipalUtils.getCurrentUserName(), namespace));
+      eventBus.dispatchEvent(
+          new ListTopicEvent(
+              PrincipalUtils.getCurrentUserName(), namespace, 
nameIdentifiers.length));

Review Comment:
   `dispatcher.listTopics(namespace)` is assumed non-null, but 
`nameIdentifiers.length` will throw an NPE if null is returned (older tests 
mocked null). Consider guarding the count calculation (null => -1/0) before 
emitting `ListTopicEvent`, or enforce/document that list operations return 
empty arrays rather than null.
   



##########
core/src/main/java/org/apache/gravitino/listener/ViewEventDispatcher.java:
##########
@@ -74,7 +74,8 @@ public NameIdentifier[] listViews(Namespace namespace) throws 
NoSuchSchemaExcept
     eventBus.dispatchEvent(new 
ListViewPreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       NameIdentifier[] identifiers = dispatcher.listViews(namespace);
-      eventBus.dispatchEvent(new 
ListViewEvent(PrincipalUtils.getCurrentUserName(), namespace));
+      eventBus.dispatchEvent(
+          new ListViewEvent(PrincipalUtils.getCurrentUserName(), namespace, 
identifiers.length));

Review Comment:
   `dispatcher.listViews(namespace)` is assumed non-null, but 
`identifiers.length` will throw an NPE if a dispatcher returns null (older 
tests mocked null). Consider guarding the length calculation (e.g., null => 
-1/0) before emitting `ListViewEvent`, or enforce/document that list methods 
must return empty arrays rather than null.
   



##########
core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java:
##########
@@ -96,7 +98,8 @@ public Catalog[] listCatalogsInfo(Namespace namespace) throws 
NoSuchMetalakeExce
     eventBus.dispatchEvent(new 
ListCatalogPreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       Catalog[] catalogs = dispatcher.listCatalogsInfo(namespace);
-      eventBus.dispatchEvent(new 
ListCatalogEvent(PrincipalUtils.getCurrentUserName(), namespace));
+      eventBus.dispatchEvent(
+          new ListCatalogEvent(PrincipalUtils.getCurrentUserName(), namespace, 
catalogs.length));

Review Comment:
   `dispatcher.listCatalogsInfo(namespace)` is assumed non-null, but 
`catalogs.length` will NPE if a dispatcher returns null. Consider guarding the 
count derivation (null => -1/0) before constructing `ListCatalogEvent`, or 
enforce/document that `listCatalogsInfo` must return an empty array instead of 
null.
   



##########
core/src/main/java/org/apache/gravitino/listener/FilesetEventDispatcher.java:
##########
@@ -77,7 +77,9 @@ public NameIdentifier[] listFilesets(Namespace namespace) 
throws NoSuchSchemaExc
     eventBus.dispatchEvent(new 
ListFilesetPreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       NameIdentifier[] nameIdentifiers = dispatcher.listFilesets(namespace);
-      eventBus.dispatchEvent(new 
ListFilesetEvent(PrincipalUtils.getCurrentUserName(), namespace));
+      eventBus.dispatchEvent(
+          new ListFilesetEvent(
+              PrincipalUtils.getCurrentUserName(), namespace, 
nameIdentifiers.length));

Review Comment:
   `dispatcher.listFilesets(namespace)` is assumed non-null, but 
`nameIdentifiers.length` will NPE if null is returned (older tests mocked 
null). Consider guarding the count derivation (null => -1/0) before emitting 
`ListFilesetEvent`, or enforce/document that list operations must return an 
empty array instead of null.
   



##########
core/src/main/java/org/apache/gravitino/listener/MetalakeEventDispatcher.java:
##########
@@ -79,7 +79,8 @@ public Metalake[] listMetalakes() {
     eventBus.dispatchEvent(new 
ListMetalakePreEvent(PrincipalUtils.getCurrentUserName()));
     try {
       Metalake[] metalakes = dispatcher.listMetalakes();
-      eventBus.dispatchEvent(new 
ListMetalakeEvent(PrincipalUtils.getCurrentUserName()));
+      eventBus.dispatchEvent(
+          new ListMetalakeEvent(PrincipalUtils.getCurrentUserName(), 
metalakes.length));

Review Comment:
   `dispatcher.listMetalakes()` is assumed non-null, but `metalakes.length` 
will NPE if null is returned (older tests mocked null). Consider guarding the 
count derivation (null => -1/0) before emitting `ListMetalakeEvent`, or 
enforce/document that list operations return empty arrays rather than null.
   



##########
core/src/main/java/org/apache/gravitino/listener/SchemaEventDispatcher.java:
##########
@@ -75,7 +75,9 @@ public NameIdentifier[] listSchemas(Namespace namespace) 
throws NoSuchCatalogExc
     eventBus.dispatchEvent(new 
ListSchemaPreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       NameIdentifier[] nameIdentifiers = dispatcher.listSchemas(namespace);
-      eventBus.dispatchEvent(new 
ListSchemaEvent(PrincipalUtils.getCurrentUserName(), namespace));
+      eventBus.dispatchEvent(
+          new ListSchemaEvent(
+              PrincipalUtils.getCurrentUserName(), namespace, 
nameIdentifiers.length));

Review Comment:
   `dispatcher.listSchemas(namespace)` is assumed non-null, but 
`nameIdentifiers.length` will NPE if the underlying dispatcher returns null 
(older tests mocked null). Consider guarding the count derivation (null => 
-1/0) before constructing `ListSchemaEvent`, or enforce/document that list APIs 
return empty arrays instead of null.
   



##########
core/src/main/java/org/apache/gravitino/listener/PartitionEventDispatcher.java:
##########
@@ -132,7 +132,9 @@ public Partition[] listPartitions(NameIdentifier ident) {
     eventBus.dispatchEvent(new 
ListPartitionPreEvent(PrincipalUtils.getCurrentUserName(), ident));
     try {
       Partition[] listPartitions = dispatcher.listPartitions(ident);
-      eventBus.dispatchEvent(new 
ListPartitionEvent(PrincipalUtils.getCurrentUserName(), ident));
+      eventBus.dispatchEvent(
+          new ListPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, 
listPartitions.length));

Review Comment:
   `dispatcher.listPartitions(ident)` is assumed non-null, but 
`listPartitions.length` will NPE if null is returned (older tests mocked null). 
Consider guarding the count derivation (null => -1/0) before emitting 
`ListPartitionEvent`, or enforce/document that list methods return empty arrays 
rather than null.
   



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