From 4e11d6bb7bc393d422bece0945890d9cdf7a3a4d Mon Sep 17 00:00:00 2001 From: wyb Date: Sat, 2 Nov 2024 04:25:46 +0800 Subject: [PATCH] [BugFix] Fix local file rename in broker (#52544) Signed-off-by: wyb (cherry picked from commit 6e5e5947b4179e2485ed040b53805be7c67ee27a) --- .../java/com/starrocks/broker/hdfs/FileSystemManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs_brokers/apache_hdfs_broker/src/broker-core/src/main/java/com/starrocks/broker/hdfs/FileSystemManager.java b/fs_brokers/apache_hdfs_broker/src/broker-core/src/main/java/com/starrocks/broker/hdfs/FileSystemManager.java index b594cc06c2cca..1a1c1cf170469 100644 --- a/fs_brokers/apache_hdfs_broker/src/broker-core/src/main/java/com/starrocks/broker/hdfs/FileSystemManager.java +++ b/fs_brokers/apache_hdfs_broker/src/broker-core/src/main/java/com/starrocks/broker/hdfs/FileSystemManager.java @@ -983,8 +983,12 @@ public void deletePath(String path, Map properties) { public void renamePath(String srcPath, String destPath, Map properties) { WildcardURI srcPathUri = new WildcardURI(srcPath); + String srcAuthority = srcPathUri.getAuthority(); WildcardURI destPathUri = new WildcardURI(destPath); - if (!srcPathUri.getAuthority().trim().equals(destPathUri.getAuthority().trim())) { + String destAuthority = destPathUri.getAuthority(); + // the authority of local file path is null, like file:///xxx. + // skip check when the authority is null. + if (srcAuthority != null && destAuthority != null && !srcAuthority.trim().equals(destAuthority.trim())) { throw new BrokerException(TBrokerOperationStatusCode.TARGET_STORAGE_SERVICE_ERROR, "only allow rename in same file system"); }