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

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 02ea353ab1a branch-3.0: [fix](fe) Using `try-with-resource` for auto 
close `RemoteFileSystem` #49637 (#49651)
02ea353ab1a is described below

commit 02ea353ab1a8d96bd75915596d447f608aa3f3c0
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sun Mar 30 10:35:41 2025 +0800

    branch-3.0: [fix](fe) Using `try-with-resource` for auto close 
`RemoteFileSystem` #49637 (#49651)
    
    Cherry-picked from #49637
    
    Co-authored-by: Lei Zhang <zhang...@selectdb.com>
---
 .../org/apache/doris/common/util/BrokerUtil.java     | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/util/BrokerUtil.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/util/BrokerUtil.java
index c5a2803b848..617d346ba3d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/BrokerUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/BrokerUtil.java
@@ -85,9 +85,8 @@ public class BrokerUtil {
     public static void parseFile(String path, BrokerDesc brokerDesc, 
List<TBrokerFileStatus> fileStatuses)
             throws UserException {
         List<RemoteFile> rfiles = new ArrayList<>();
-        try {
-            RemoteFileSystem fileSystem = FileSystemFactory.get(
-                    brokerDesc.getName(), brokerDesc.getStorageType(), 
brokerDesc.getProperties());
+        try (RemoteFileSystem fileSystem = FileSystemFactory.get(
+                    brokerDesc.getName(), brokerDesc.getStorageType(), 
brokerDesc.getProperties())) {
             Status st = fileSystem.globList(path, rfiles, false);
             if (!st.ok()) {
                 throw new UserException(st.getErrMsg());
@@ -108,12 +107,17 @@ public class BrokerUtil {
     }
 
     public static void deleteDirectoryWithFileSystem(String path, BrokerDesc 
brokerDesc) throws UserException {
-        RemoteFileSystem fileSystem = FileSystemFactory.get(
-                brokerDesc.getName(), brokerDesc.getStorageType(), 
brokerDesc.getProperties());
-        Status st = fileSystem.deleteDirectory(path);
-        if (!st.ok()) {
+        try (RemoteFileSystem fileSystem = FileSystemFactory.get(
+                    brokerDesc.getName(), brokerDesc.getStorageType(), 
brokerDesc.getProperties())) {
+            Status st = fileSystem.deleteDirectory(path);
+            if (!st.ok()) {
+                throw new UserException(brokerDesc.getName() +  " delete 
directory exception. path="
+                        + path + ", err: " + st.getErrMsg());
+            }
+        } catch (Exception e) {
+            LOG.warn("{} delete directory exception, path={}", 
brokerDesc.getName(), path, e);
             throw new UserException(brokerDesc.getName() +  " delete directory 
exception. path="
-                    + path + ", err: " + st.getErrMsg());
+                    + path + ", err: " + e.getMessage());
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to