This is an automated email from the ASF dual-hosted git repository.
mchades pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 42759f9adb [#8858] fix(gvfs-java) remove filesetPathNotFoundException
Java (#8859)
42759f9adb is described below
commit 42759f9adb80b0ab93e78f3503787df7b8aad046
Author: Junda Yang <[email protected]>
AuthorDate: Tue Oct 21 20:27:39 2025 -0700
[#8858] fix(gvfs-java) remove filesetPathNotFoundException Java (#8859)
### What changes were proposed in this pull request?
Remove FilesetPathNotFoundException and throws FileNotFoundException
instead.
### Why are the changes needed?
When use fsspec through JNI, the JNI layer cannot convert a
[FilesetPathNotFoundException](https://github.com/datastrato/gravitino-uber/blob/10ab935cf592c4f81693cc7ffda04c13c06bd338/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetPathNotFoundException.java#L24C14-L24C42)
into Python's FileType.NotFound.
As a result, when fsspec tries to list the file, it ends up with an
"unknown error".
Fix: #8858
### Does this PR introduce _any_ user-facing change?
FilesetPathNotFoundException will be removed. Users will see
FileNotFoundException instead.
### How was this patch tested?
1. unit tests.
2. tested in our environment
---
.../filesystem/hadoop/BaseGVFSOperations.java | 27 ++++++------
.../filesystem/hadoop/DefaultGVFSOperations.java | 13 +++---
.../hadoop/FilesetPathNotFoundException.java | 50 ----------------------
.../hadoop/GravitinoVirtualFileSystem.java | 20 ++++-----
.../gravitino/filesystem/hadoop/TestGvfsBase.java | 27 ++++++------
5 files changed, 42 insertions(+), 95 deletions(-)
diff --git
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java
b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java
index 7c93ae9784..9ffaaf5760 100644
---
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java
+++
b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java
@@ -38,6 +38,7 @@ import com.google.common.collect.Sets;
import com.google.common.collect.Streams;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.io.Closeable;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
@@ -213,9 +214,9 @@ public abstract class BaseGVFSOperations implements
Closeable {
* Set the working directory. Same as {@link
FileSystem#setWorkingDirectory(Path)}.
*
* @param gvfsDir the new working directory.
- * @throws FilesetPathNotFoundException if the fileset path is not found.
+ * @throws FileNotFoundException if the fileset path is not found.
*/
- public abstract void setWorkingDirectory(Path gvfsDir) throws
FilesetPathNotFoundException;
+ public abstract void setWorkingDirectory(Path gvfsDir) throws
FileNotFoundException;
/**
* Create a file. Same as {@link FileSystem#create(Path, FsPermission,
boolean, int, short, long,
@@ -394,11 +395,11 @@ public abstract class BaseGVFSOperations implements
Closeable {
* @param locationName the location name.
* @param operation the fileset data operation.
* @return the actual file path.
- * @throws FilesetPathNotFoundException if the fileset path is not found.
+ * @throws FileNotFoundException if the fileset path is not found.
*/
protected Path getActualFilePath(
Path gvfsPath, String locationName, FilesetDataOperation operation)
- throws FilesetPathNotFoundException {
+ throws FileNotFoundException {
NameIdentifier filesetIdent = extractIdentifier(metalakeName,
gvfsPath.toString());
String subPath = getSubPathFromGvfsPath(filesetIdent, gvfsPath.toString());
NameIdentifier catalogIdent =
@@ -415,14 +416,14 @@ public abstract class BaseGVFSOperations implements
Closeable {
} catch (NoSuchCatalogException | CatalogNotInUseException e) {
String message = String.format("Cannot get fileset catalog by
identifier: %s", catalogIdent);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
} catch (NoSuchFilesetException e) {
String message =
String.format(
"Cannot get fileset by fileset identifier: %s, sub_path %s",
filesetIdent, subPath);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
} catch (NoSuchLocationNameException e) {
String message =
@@ -430,7 +431,7 @@ public abstract class BaseGVFSOperations implements
Closeable {
"Location name not found by fileset identifier: %s, sub_path %s,
location_name %s",
filesetIdent, subPath, locationName);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
}
Path actualFilePath = new Path(fileLocation);
@@ -520,10 +521,10 @@ public abstract class BaseGVFSOperations implements
Closeable {
* @param filesetPath the virtual path.
* @param locationName the location name. null means the default location.
* @return the actual file system.
- * @throws FilesetPathNotFoundException if the fileset path is not found.
+ * @throws FileNotFoundException if the fileset path is not found.
*/
protected FileSystem getActualFileSystem(Path filesetPath, String
locationName)
- throws FilesetPathNotFoundException {
+ throws FileNotFoundException {
NameIdentifier filesetIdent = extractIdentifier(metalakeName,
filesetPath.toString());
return getActualFileSystemByLocationName(filesetIdent, locationName);
}
@@ -583,7 +584,7 @@ public abstract class BaseGVFSOperations implements
Closeable {
}
private FileSystem getActualFileSystemByLocationName(
- NameIdentifier filesetIdent, String locationName) throws
FilesetPathNotFoundException {
+ NameIdentifier filesetIdent, String locationName) throws
FileNotFoundException {
NameIdentifier catalogIdent =
NameIdentifier.of(filesetIdent.namespace().level(0),
filesetIdent.namespace().level(1));
try {
@@ -627,14 +628,14 @@ public abstract class BaseGVFSOperations implements
Closeable {
String message =
String.format("Cannot get fileset catalog by identifier: %s",
catalogIdent);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
}
if (cause instanceof NoSuchFilesetException) {
String message =
String.format("Cannot get fileset by fileset identifier: %s",
filesetIdent);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
}
if (cause instanceof NoSuchLocationNameException) {
@@ -643,7 +644,7 @@ public abstract class BaseGVFSOperations implements
Closeable {
"Location name not found by fileset identifier: %s,
location_name %s",
filesetIdent, locationName);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
}
throw e;
diff --git
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/DefaultGVFSOperations.java
b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/DefaultGVFSOperations.java
index 7390a7d26c..5b26b1c2be 100644
---
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/DefaultGVFSOperations.java
+++
b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/DefaultGVFSOperations.java
@@ -22,6 +22,7 @@ import static
org.apache.gravitino.filesystem.hadoop.GravitinoVirtualFileSystemU
import static
org.apache.gravitino.filesystem.hadoop.GravitinoVirtualFileSystemUtils.getSubPathFromGvfsPath;
import com.google.common.base.Preconditions;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import org.apache.gravitino.NameIdentifier;
@@ -67,7 +68,7 @@ public class DefaultGVFSOperations extends BaseGVFSOperations
{
}
@Override
- public synchronized void setWorkingDirectory(Path gvfsDir) throws
FilesetPathNotFoundException {
+ public synchronized void setWorkingDirectory(Path gvfsDir) throws
FileNotFoundException {
FileSystem actualFs = getActualFileSystem(gvfsDir, currentLocationName());
Path actualFilePath =
getActualFilePath(gvfsDir, currentLocationName(),
FilesetDataOperation.SET_WORKING_DIR);
@@ -90,7 +91,7 @@ public class DefaultGVFSOperations extends BaseGVFSOperations
{
getActualFilePath(gvfsPath, currentLocationName(),
FilesetDataOperation.CREATE);
return actualFs.create(
actualFilePath, permission, overwrite, bufferSize, replication,
blockSize, progress);
- } catch (FilesetPathNotFoundException e) {
+ } catch (FileNotFoundException e) {
String message =
"Fileset is not found for path: "
+ gvfsPath
@@ -138,7 +139,7 @@ public class DefaultGVFSOperations extends
BaseGVFSOperations {
Path actualFilePath =
getActualFilePath(gvfsPath, currentLocationName(),
FilesetDataOperation.DELETE);
return actualFs.delete(actualFilePath, recursive);
- } catch (FilesetPathNotFoundException e) {
+ } catch (FileNotFoundException e) {
return false;
}
}
@@ -190,7 +191,7 @@ public class DefaultGVFSOperations extends
BaseGVFSOperations {
Path actualFilePath =
getActualFilePath(gvfsPath, currentLocationName(),
FilesetDataOperation.MKDIRS);
return actualFs.mkdirs(actualFilePath, permission);
- } catch (FilesetPathNotFoundException e) {
+ } catch (FileNotFoundException e) {
String message =
"Fileset is not found for path: "
+ gvfsPath
@@ -209,7 +210,7 @@ public class DefaultGVFSOperations extends
BaseGVFSOperations {
getActualFilePath(
gvfsPath, currentLocationName(),
FilesetDataOperation.GET_DEFAULT_REPLICATION);
return actualFs.getDefaultReplication(actualFilePath);
- } catch (FilesetPathNotFoundException e) {
+ } catch (FileNotFoundException e) {
return 1;
}
}
@@ -222,7 +223,7 @@ public class DefaultGVFSOperations extends
BaseGVFSOperations {
getActualFilePath(
gvfsPath, currentLocationName(),
FilesetDataOperation.GET_DEFAULT_BLOCK_SIZE);
return actualFs.getDefaultBlockSize(actualFilePath);
- } catch (FilesetPathNotFoundException e) {
+ } catch (FileNotFoundException e) {
return defaultBlockSize();
}
}
diff --git
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetPathNotFoundException.java
b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetPathNotFoundException.java
deleted file mode 100644
index c0fbc6760f..0000000000
---
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/FilesetPathNotFoundException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.gravitino.filesystem.hadoop;
-
-import java.io.FileNotFoundException;
-
-/** Exception thrown when the catalog, schema or fileset not existed for a
given GVFS path. */
-public class FilesetPathNotFoundException extends FileNotFoundException {
-
- /** Creates a new FilesetPathNotFoundException instance. */
- public FilesetPathNotFoundException() {
- super();
- }
-
- /**
- * Creates a new FilesetPathNotFoundException instance with the given
message.
- *
- * @param message The message of the exception.
- */
- public FilesetPathNotFoundException(String message) {
- super(message);
- }
-
- /**
- * Creates a new FilesetPathNotFoundException instance with the given
message and cause.
- *
- * @param message The message of the exception.
- * @param cause The cause of the exception.
- */
- public FilesetPathNotFoundException(String message, Throwable cause) {
- super(message);
- initCause(cause);
- }
-}
diff --git
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java
b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java
index ea87e236f7..346c4724b1 100644
---
a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java
+++
b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java
@@ -21,6 +21,7 @@ package org.apache.gravitino.filesystem.hadoop;
import static
org.apache.gravitino.filesystem.hadoop.GravitinoVirtualFileSystemUtils.getConfigMap;
import com.google.common.annotations.VisibleForTesting;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
@@ -135,7 +136,7 @@ public class GravitinoVirtualFileSystem extends FileSystem {
return null;
},
FilesetDataOperation.SET_WORKING_DIR);
- } catch (FilesetPathNotFoundException e) {
+ } catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
this.workingDirectory = newPath;
@@ -176,8 +177,7 @@ public class GravitinoVirtualFileSystem extends FileSystem {
} catch (NoSuchCatalogException
| CatalogNotInUseException
| NoSuchFilesetException
- | NoSuchLocationNameException
- | FilesetPathNotFoundException e) {
+ | NoSuchLocationNameException e) {
String message =
"Fileset is not found for path: "
+ path
@@ -218,7 +218,7 @@ public class GravitinoVirtualFileSystem extends FileSystem {
recursive,
runWithExceptionTranslation(
() -> operations.delete(newPath, recursive),
FilesetDataOperation.DELETE));
- } catch (FilesetPathNotFoundException e) {
+ } catch (FileNotFoundException e) {
return false;
}
}
@@ -247,8 +247,7 @@ public class GravitinoVirtualFileSystem extends FileSystem {
} catch (NoSuchCatalogException
| CatalogNotInUseException
| NoSuchFilesetException
- | NoSuchLocationNameException
- | FilesetPathNotFoundException e) {
+ | NoSuchLocationNameException e) {
String message =
"Fileset is not found for path: "
+ newPath
@@ -310,24 +309,23 @@ public class GravitinoVirtualFileSystem extends
FileSystem {
}
private <R, E extends IOException> R runWithExceptionTranslation(
- Executable<R, E> executable, FilesetDataOperation operation)
- throws FilesetPathNotFoundException, E {
+ Executable<R, E> executable, FilesetDataOperation operation) throws
FileNotFoundException, E {
try {
return executable.execute();
} catch (NoSuchCatalogException | CatalogNotInUseException e) {
String message = String.format("Cannot get fileset catalog during %s",
operation);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
} catch (NoSuchFilesetException e) {
String message = String.format("Cannot get fileset during %s",
operation);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
} catch (NoSuchLocationNameException e) {
String message = String.format("Cannot find location name during %s",
operation);
LOG.warn(message, e);
- throw new FilesetPathNotFoundException(message, e);
+ throw (FileNotFoundException) new
FileNotFoundException(message).initCause(e);
} catch (IOException e) {
throw e;
diff --git
a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java
b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java
index fa6b79161d..a0c29014fe 100644
---
a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java
+++
b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java
@@ -45,6 +45,7 @@ import static org.mockserver.model.HttpResponse.response;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.ImmutableMap;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.SocketTimeoutException;
@@ -167,8 +168,7 @@ public class TestGvfsBase extends GravitinoMockServerBase {
Mockito.doThrow(new NoSuchFilesetException("fileset not found"))
.when(mockOps)
.open(any(), anyInt());
- assertThrows(
- FilesetPathNotFoundException.class, () -> fs.open(new
Path("gvfs://fileset/"), 1024));
+ assertThrows(FileNotFoundException.class, () -> fs.open(new
Path("gvfs://fileset/"), 1024));
// test create
Mockito.doThrow(new NoSuchCatalogException("fileset catalog not found"))
@@ -184,15 +184,14 @@ public class TestGvfsBase extends GravitinoMockServerBase
{
Mockito.doThrow(new NoSuchLocationNameException("location name not
found"))
.when(mockOps)
.append(any(), anyInt(), any());
- assertThrows(
- FilesetPathNotFoundException.class, () -> fs.append(new
Path("gvfs://fileset/"), 1024));
+ assertThrows(FileNotFoundException.class, () -> fs.append(new
Path("gvfs://fileset/"), 1024));
// test rename
Mockito.doThrow(new NoSuchFilesetException("fileset not found"))
.when(mockOps)
.rename(any(), any());
assertThrows(
- FilesetPathNotFoundException.class,
+ FileNotFoundException.class,
() -> fs.rename(new Path("gvfs://fileset/"), new
Path("gvfs://fileset/new")));
// test delete
@@ -206,21 +205,19 @@ public class TestGvfsBase extends GravitinoMockServerBase
{
.when(mockOps)
.getFileStatus(any());
assertThrows(
- FilesetPathNotFoundException.class, () -> fs.getFileStatus(new
Path("gvfs://fileset/")));
+ FileNotFoundException.class, () -> fs.getFileStatus(new
Path("gvfs://fileset/")));
// test listStatus
Mockito.doThrow(new NoSuchFilesetException("fileset not found"))
.when(mockOps)
.listStatus(any());
- assertThrows(
- FilesetPathNotFoundException.class, () -> fs.listStatus(new
Path("gvfs://fileset/")));
+ assertThrows(FileNotFoundException.class, () -> fs.listStatus(new
Path("gvfs://fileset/")));
// test listStatus
Mockito.doThrow(new NoSuchFilesetException("fileset not found"))
.when(mockOps)
.listStatus(any());
- assertThrows(
- FilesetPathNotFoundException.class, () -> fs.listStatus(new
Path("gvfs://fileset/")));
+ assertThrows(FileNotFoundException.class, () -> fs.listStatus(new
Path("gvfs://fileset/")));
// test mkdirs
Mockito.doThrow(new NoSuchFilesetException("fileset not found"))
@@ -973,17 +970,17 @@ public class TestGvfsBase extends GravitinoMockServerBase
{
Path testPath = new Path(managedFilesetPath + "/test.txt");
assertThrows(RuntimeException.class, () ->
fs.setWorkingDirectory(testPath));
- assertThrows(FilesetPathNotFoundException.class, () ->
fs.open(testPath));
+ assertThrows(FileNotFoundException.class, () -> fs.open(testPath));
assertThrows(IOException.class, () -> fs.create(testPath));
- assertThrows(FilesetPathNotFoundException.class, () ->
fs.append(testPath));
+ assertThrows(FileNotFoundException.class, () -> fs.append(testPath));
Path testPath1 = new Path(managedFilesetPath + "/test1.txt");
- assertThrows(FilesetPathNotFoundException.class, () ->
fs.rename(testPath, testPath1));
+ assertThrows(FileNotFoundException.class, () -> fs.rename(testPath,
testPath1));
assertFalse(fs.delete(testPath, true));
- assertThrows(FilesetPathNotFoundException.class, () ->
fs.getFileStatus(testPath));
- assertThrows(FilesetPathNotFoundException.class, () ->
fs.listStatus(testPath));
+ assertThrows(FileNotFoundException.class, () ->
fs.getFileStatus(testPath));
+ assertThrows(FileNotFoundException.class, () -> fs.listStatus(testPath));
assertThrows(IOException.class, () -> fs.mkdirs(testPath));