Skip to content

Commit

Permalink
[MINOR] DataStream need in closeure in FileSystemBasedLockProvider (#…
Browse files Browse the repository at this point in the history
…10411)

Co-authored-by: xuyu <11161569@vivo.com>
  • Loading branch information
2 people authored and yihua committed Feb 27, 2024
1 parent 353d281 commit 5faefcd
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,10 @@ private boolean checkIfExpired() {
}

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);
Expand All @@ -182,11 +180,9 @@ public void initLockInfo() {
}

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 = "";
}
Expand Down

0 comments on commit 5faefcd

Please sign in to comment.