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


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java:
##########
@@ -690,16 +770,28 @@ protected Fileset getFileset(NameIdentifier filesetIdent) 
{
    * @return the schema.
    */
   protected Schema getSchema(NameIdentifier schemaIdent) {
-    return filesetMetadataCache
+    return getSchema(schemaIdent, (Catalog) 
getFilesetCatalog(catalogIdentOf(schemaIdent)));

Review Comment:
   These new casts assume the object returned by getFilesetCatalog(...) also 
implements Catalog. Previously, the code path could avoid this cast unless 
autoCreateLocation was enabled, but now buildFileSystem() and 
getSchema(schemaIdent) will always cast, which can introduce a 
ClassCastException at runtime if FilesetCatalog is not a Catalog 
implementation. To fix this, avoid casting FilesetCatalog to Catalog: 
load/obtain the Catalog explicitly once (e.g., via 
gravitinoClient.loadCatalog(...)) and derive the FilesetCatalog from it 
(catalog.asFilesetCatalog()), then thread both objects through resolve/build 
helpers (or change getFilesetCatalog to return Catalog and add a helper to get 
the FilesetCatalog view).



##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java:
##########
@@ -728,27 +828,43 @@ protected FileSystem getActualFileSystemByLocationName(
           filesetIdent);
 
       Path targetLocation = new 
Path(fileset.storageLocations().get(targetLocationName));
-      Map<String, String> allProperties = getAllProperties(filesetIdent);
-      allProperties.putAll(
+      Catalog catalog = (Catalog) filesetCatalog;

Review Comment:
   These new casts assume the object returned by getFilesetCatalog(...) also 
implements Catalog. Previously, the code path could avoid this cast unless 
autoCreateLocation was enabled, but now buildFileSystem() and 
getSchema(schemaIdent) will always cast, which can introduce a 
ClassCastException at runtime if FilesetCatalog is not a Catalog 
implementation. To fix this, avoid casting FilesetCatalog to Catalog: 
load/obtain the Catalog explicitly once (e.g., via 
gravitinoClient.loadCatalog(...)) and derive the FilesetCatalog from it 
(catalog.asFilesetCatalog()), then thread both objects through resolve/build 
helpers (or change getFilesetCatalog to return Catalog and add a helper to get 
the FilesetCatalog view).



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