FangYongs commented on code in PR #23063:
URL: https://github.com/apache/flink/pull/23063#discussion_r1283906870


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FileCatalogStore.java:
##########
@@ -172,22 +185,30 @@ public void removeCatalog(String catalogName, boolean 
ignoreIfNotExists)
     @Override
     public Optional<CatalogDescriptor> getCatalog(String catalogName) throws 
CatalogException {
         checkOpenState();
-
-        Path path = getCatalogPath(catalogName);
+        Path catalogPath = getCatalogPath(catalogName);
         try {
-            File file = path.toFile();
-            if (!file.exists()) {
-                LOG.warn("Catalog {}'s store file %s does not exist.", 
catalogName, path);
+            FileSystem fs = catalogPath.getFileSystem();
+
+            if (!fs.exists(catalogPath)) {
                 return Optional.empty();
             }
-            String content = FileUtils.readFile(file, charset);
-            Map<String, String> options = yaml.load(content);
-            return Optional.of(CatalogDescriptor.of(catalogName, 
Configuration.fromMap(options)));
-        } catch (Throwable t) {
+
+            try (FSDataInputStream is = fs.open(catalogPath)) {
+                Map<String, String> configMap =
+                        YAML_MAPPER.readValue(is, new 
TypeReference<Map<String, String>>() {});
+
+                CatalogDescriptor catalog =
+                        CatalogDescriptor.of(catalogName, 
Configuration.fromMap(configMap));
+
+                return Optional.of(catalog);
+            }
+        } catch (CatalogException e) {
+            throw e;

Review Comment:
   Same as above



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to