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

yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 10bc664c67d [MINOR] DataStream need in closeure in 
FileSystemBasedLockProvider (#10411)
10bc664c67d is described below

commit 10bc664c67d00c0c2a08bc20bf5cb709b471168e
Author: xuzifu666 <[email protected]>
AuthorDate: Wed Dec 27 13:13:31 2023 +0800

    [MINOR] DataStream need in closeure in FileSystemBasedLockProvider (#10411)
    
    Co-authored-by: xuyu <[email protected]>
---
 .../hudi/client/transaction/lock/FileSystemBasedLockProvider.java | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git 
a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java
 
b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java
index ddf42bb23ee..48d67b76d0a 100644
--- 
a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java
+++ 
b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java
@@ -163,12 +163,10 @@ public class FileSystemBasedLockProvider implements 
LockProvider<String>, Serial
   }
 
   private void acquireLock() {
-    try {
+    try (FSDataOutputStream fos = fs.create(this.lockFile, false)) {
       if (!fs.exists(this.lockFile)) {
-        FSDataOutputStream fos = fs.create(this.lockFile, false);
         initLockInfo();
         fos.writeBytes(lockInfo.toString());
-        fos.close();
       }
     } catch (IOException e) {
       throw new 
HoodieIOException(generateLogStatement(LockState.FAILED_TO_ACQUIRE), e);
@@ -182,11 +180,9 @@ public class FileSystemBasedLockProvider implements 
LockProvider<String>, Serial
   }
 
   public void reloadCurrentOwnerLockInfo() {
-    try {
+    try (FSDataInputStream fis = fs.open(this.lockFile)) {
       if (fs.exists(this.lockFile)) {
-        FSDataInputStream fis = fs.open(this.lockFile);
         this.currentOwnerLockInfo = FileIOUtils.readAsUTFString(fis);
-        fis.close();
       } else {
         this.currentOwnerLockInfo = "";
       }

Reply via email to