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 <[email protected]>
  • Loading branch information
xuzifu666 and xuyu authored Dec 27, 2023
1 parent 51048ac commit 10bc664
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 10bc664

Please sign in to comment.