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

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


The following commit(s) were added to refs/heads/master by this push:
     new aab0bf8b06 [common] Propagate checked IOException from 
RESTTokenFileIO#fileIO (#9638)
aab0bf8b06 is described below

commit aab0bf8b067b9b3c74861bd3590ae2d2e82659de
Author: YangJie <[email protected]>
AuthorDate: Thu Sep 10 02:53:58 2026 -0400

    [common] Propagate checked IOException from RESTTokenFileIO#fileIO (#9638)
---
 .../org/apache/paimon/rest/RESTTokenFileIO.java    |  7 +----
 .../apache/paimon/rest/RESTTokenFileIOTest.java    | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git 
a/paimon-common/src/main/java/org/apache/paimon/rest/RESTTokenFileIO.java 
b/paimon-common/src/main/java/org/apache/paimon/rest/RESTTokenFileIO.java
index a431247000..d3618a3c14 100644
--- a/paimon-common/src/main/java/org/apache/paimon/rest/RESTTokenFileIO.java
+++ b/paimon-common/src/main/java/org/apache/paimon/rest/RESTTokenFileIO.java
@@ -45,7 +45,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.io.UncheckedIOException;
 import java.time.Duration;
 import java.util.Map;
 import java.util.concurrent.Executors;
@@ -227,11 +226,7 @@ public class RESTTokenFileIO implements FileIO {
                             catalogContext.hadoopConf(),
                             catalogContext.preferIO(),
                             catalogContext.fallbackIO());
-            try {
-                fileIO = FileIO.get(path, context);
-            } catch (IOException e) {
-                throw new UncheckedIOException(e);
-            }
+            fileIO = FileIO.get(path, context);
             FILE_IO_CACHE.put(token, fileIO);
             return fileIO;
         }
diff --git 
a/paimon-common/src/test/java/org/apache/paimon/rest/RESTTokenFileIOTest.java 
b/paimon-common/src/test/java/org/apache/paimon/rest/RESTTokenFileIOTest.java
index 4b64a682a7..8aefb6b4a6 100644
--- 
a/paimon-common/src/test/java/org/apache/paimon/rest/RESTTokenFileIOTest.java
+++ 
b/paimon-common/src/test/java/org/apache/paimon/rest/RESTTokenFileIOTest.java
@@ -97,6 +97,36 @@ class RESTTokenFileIOTest {
                 .hasMessageContaining("bound table root");
     }
 
+    @Test
+    void testFileIOCreationFailureSurfacesAsCheckedIOException() throws 
IOException {
+        Path tableRoot = new Path("resttoken-broken://bucket/table");
+        // the loader's access check fails, so FileIO.get cannot produce an 
inner FileIO
+        FileIO delegate = mock(FileIO.class);
+        when(delegate.exists(any())).thenThrow(new IOException("token fs 
unavailable"));
+        FileIOLoader loader = mock(FileIOLoader.class);
+        when(loader.getScheme()).thenReturn("resttoken-broken");
+        when(loader.load(any())).thenReturn(delegate);
+        RESTApi api = mock(RESTApi.class);
+        Identifier identifier = Identifier.create("db", "table");
+        // a unique token, so the static token-keyed FileIO cache cannot serve 
another test's
+        // delegate and the creation path actually runs
+        when(api.loadTableToken(identifier))
+                .thenReturn(
+                        new GetTableTokenResponse(
+                                Collections.singletonMap("token", 
UUID.randomUUID().toString()),
+                                Long.MAX_VALUE));
+        RESTTokenFileIO fileIO =
+                new RESTTokenFileIO(
+                        CatalogContext.create(new Options(), loader, null),
+                        api,
+                        identifier,
+                        tableRoot);
+
+        // FileIO operations declare IOException; failing to create the inner 
FileIO must
+        // surface the same way instead of bypassing callers as 
UncheckedIOException
+        assertThatThrownBy(() -> 
fileIO.exists(tableRoot)).isInstanceOf(IOException.class);
+    }
+
     @Test
     void testTryToWriteAtomicReachesInnerOverride() throws IOException {
         Path tableRoot = new Path("oss://bucket/table");

Reply via email to