From e6150d866a9b2aff654de602097a7b799ad1aa36 Mon Sep 17 00:00:00 2001 From: forwardxu Date: Sat, 16 May 2026 11:15:14 +0800 Subject: [PATCH] Preserve exception cause in RpcServiceBase error handling The catch blocks in getKvSnapshotMetadata() and getFileSystemSecurityToken() were discarding the original exception cause, making it very difficult to diagnose root causes in production. Changes: - Pass the caught exception as the cause parameter to SecurityTokenException (which already supports it) - Add a (String, Throwable) constructor to KvSnapshotNotExistException and pass the caught exception as the cause This is consistent with all other exception re-throwing patterns in the codebase (e.g., CoordinatorService, HadoopConfSerde, PaimonLakeCatalog) which always preserve the original exception chain. --- .../apache/fluss/exception/KvSnapshotNotExistException.java | 4 ++++ .../main/java/org/apache/fluss/server/RpcServiceBase.java | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fluss-common/src/main/java/org/apache/fluss/exception/KvSnapshotNotExistException.java b/fluss-common/src/main/java/org/apache/fluss/exception/KvSnapshotNotExistException.java index b66b90e722..9aa147880e 100644 --- a/fluss-common/src/main/java/org/apache/fluss/exception/KvSnapshotNotExistException.java +++ b/fluss-common/src/main/java/org/apache/fluss/exception/KvSnapshotNotExistException.java @@ -32,4 +32,8 @@ public class KvSnapshotNotExistException extends ApiException { public KvSnapshotNotExistException(String message) { super(message); } + + public KvSnapshotNotExistException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/fluss-server/src/main/java/org/apache/fluss/server/RpcServiceBase.java b/fluss-server/src/main/java/org/apache/fluss/server/RpcServiceBase.java index dedef6ea8b..47737a3263 100644 --- a/fluss-server/src/main/java/org/apache/fluss/server/RpcServiceBase.java +++ b/fluss-server/src/main/java/org/apache/fluss/server/RpcServiceBase.java @@ -434,7 +434,8 @@ public CompletableFuture getKvSnapshotMetadata( throw new KvSnapshotNotExistException( String.format( "Failed to get kv snapshot metadata for table bucket %s and snapshot id %s. Error: %s", - tableBucket, snapshotId, e.getMessage())); + tableBucket, snapshotId, e.getMessage()), + e); } } @@ -456,7 +457,7 @@ public CompletableFuture getFileSystemSecuri remoteFileSystem.getUri().getScheme(), securityToken)); } catch (Exception e) { throw new SecurityTokenException( - "Failed to get file access security token: " + e.getMessage()); + "Failed to get file access security token: " + e.getMessage(), e); } }