This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 944598d85ed [fix](fe) Using `try-with-resource` for auto close
`RemoteFileSystem` (#49637)
944598d85ed is described below
commit 944598d85edf48c8354ef3eeddd2cc526ea6d7a3
Author: Lei Zhang <[email protected]>
AuthorDate: Fri Mar 28 22:12:03 2025 +0800
[fix](fe) Using `try-with-resource` for auto close `RemoteFileSystem`
(#49637)
---
.../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]