Copilot commented on code in PR #6311:
URL: https://github.com/apache/hive/pull/6311#discussion_r2867287925


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/TruncateTableHandler.java:
##########
@@ -286,7 +286,7 @@ public static void addTruncateBaseFile(Path location, long 
writeId, Configuratio
   }
 
   @Override
-  protected String getMessagePrefix() {
+  public String toString() {
     return "TruncateTableHandler [" + id + "] -  truncate table for " +
         TableName.getQualified(catName, dbName, table.getTableName()) + ":";

Review Comment:
   `TruncateTableHandler.toString()` dereferences `table.getTableName()`. As 
with other handlers, `toString()` can be invoked before `beforeExecute()` 
initializes `table` (via status polling or cancellation), which would throw an 
NPE and interfere with async/progress reporting. Make `toString()` null-safe 
(e.g., avoid dereferencing `table` until it is initialized, or use request 
fields as a fallback).
   ```suggestion
       String tableName = (table != null) ? table.getTableName() : "<table not 
initialized>";
       return "TruncateTableHandler [" + id + "] -  truncate table for " +
           TableName.getQualified(catName, dbName, tableName) + ":";
   ```



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/CreateTableHandler.java:
##########
@@ -386,7 +386,7 @@ protected void beforeExecute() throws TException, 
IOException {
   }
 
   @Override
-  protected String getMessagePrefix() {
+  public String toString() {
     return "CreateTableHandler [" + id + "] -  create table for " +
         TableName.getQualified(tbl.getCatName(), tbl.getDbName(), 
tbl.getTableName()) + ":";

Review Comment:
   `CreateTableHandler.toString()` dereferences `tbl` (and its fields). 
`toString()` can be called by AbstractRequestHandler immediately after 
construction (e.g., in getRequestStatus/cancelRequest) before `beforeExecute()` 
assigns `tbl`, which can trigger an NPE and break request status/progress 
reporting. Make this `toString()` null-safe (e.g., fall back to class/id or 
request-level identifiers when `tbl` is not yet initialized).
   ```suggestion
       String tableName;
       if (tbl != null) {
         tableName = TableName.getQualified(tbl.getCatName(), tbl.getDbName(), 
tbl.getTableName());
       } else {
         tableName = "<uninitialized table>";
       }
       return "CreateTableHandler [" + id + "] -  create table for " + 
tableName + ":";
   ```



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