This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 8f15e62de55 branch-2.1: [fix](fe) Using `try-with-resource` for auto
close `RemoteFileSystem` #49637 (#49652)
8f15e62de55 is described below
commit 8f15e62de555d0f780eb798b62a67039f38c6b3b
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Mar 29 08:54:50 2025 +0800
branch-2.1: [fix](fe) Using `try-with-resource` for auto close
`RemoteFileSystem` #49637 (#49652)
Cherry-picked from #49637
Co-authored-by: Lei Zhang <[email protected]>
---
.../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: [email protected]
For additional commands, e-mail: [email protected]