You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2022/04/03 21:45:02 UTC

[iceberg] branch master updated: Core: Minor review fixes for ResolvingFileIO (#3603)

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

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new b784c5f5e Core: Minor review fixes for ResolvingFileIO (#3603)
b784c5f5e is described below

commit b784c5f5e0a142cc2b764b5dada728659ae4cb58
Author: Ryan Blue <bl...@apache.org>
AuthorDate: Sun Apr 3 14:44:56 2022 -0700

    Core: Minor review fixes for ResolvingFileIO (#3603)
---
 .../org/apache/iceberg/io/ResolvingFileIO.java     | 25 ++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/core/src/main/java/org/apache/iceberg/io/ResolvingFileIO.java b/core/src/main/java/org/apache/iceberg/io/ResolvingFileIO.java
index f57bb54db..03cc9a2de 100644
--- a/core/src/main/java/org/apache/iceberg/io/ResolvingFileIO.java
+++ b/core/src/main/java/org/apache/iceberg/io/ResolvingFileIO.java
@@ -38,11 +38,9 @@ import org.slf4j.LoggerFactory;
  */
 public class ResolvingFileIO implements FileIO, HadoopConfigurable {
   private static final Logger LOG = LoggerFactory.getLogger(ResolvingFileIO.class);
-  private static final String DEFAULT_SCHEME = "fs";
   private static final String FALLBACK_IMPL = "org.apache.iceberg.hadoop.HadoopFileIO";
   private static final String S3_FILE_IO_IMPL = "org.apache.iceberg.aws.s3.S3FileIO";
   private static final Map<String, String> SCHEME_TO_FILE_IO = ImmutableMap.of(
-      DEFAULT_SCHEME, FALLBACK_IMPL,
       "s3", S3_FILE_IO_IMPL,
       "s3a", S3_FILE_IO_IMPL,
       "s3n", S3_FILE_IO_IMPL
@@ -129,15 +127,20 @@ public class ResolvingFileIO implements FileIO, HadoopConfigurable {
       try {
         io = CatalogUtil.loadFileIO(impl, properties, conf);
       } catch (IllegalArgumentException e) {
-        LOG.warn("Failed to load FileIO implementation: {}, falling back to {}", impl, FALLBACK_IMPL, e);
-        try {
-          // couldn't load the normal class, fall back to HadoopFileIO
-          io = CatalogUtil.loadFileIO(FALLBACK_IMPL, properties, conf);
-        } catch (IllegalArgumentException suppressed) {
-          LOG.warn("Failed to load FileIO implementation: {} (fallback)", FALLBACK_IMPL, suppressed);
-          // both attempts failed, throw the original exception with the later exception suppressed
-          e.addSuppressed(suppressed);
+        if (impl.equals(FALLBACK_IMPL)) {
+          // no implementation to fall back to, throw the exception
           throw e;
+        } else {
+          // couldn't load the normal class, fall back to HadoopFileIO
+          LOG.warn("Failed to load FileIO implementation: {}, falling back to {}", impl, FALLBACK_IMPL, e);
+          try {
+            io = CatalogUtil.loadFileIO(FALLBACK_IMPL, properties, conf);
+          } catch (IllegalArgumentException suppressed) {
+            LOG.warn("Failed to load FileIO implementation: {} (fallback)", FALLBACK_IMPL, suppressed);
+            // both attempts failed, throw the original exception with the later exception suppressed
+            e.addSuppressed(suppressed);
+            throw e;
+          }
         }
       }
 
@@ -157,6 +160,6 @@ public class ResolvingFileIO implements FileIO, HadoopConfigurable {
       return location.substring(0, colonPos);
     }
 
-    return DEFAULT_SCHEME;
+    return null;
   }
 }