Skip to content

Commit

Permalink
fix: ThreadId miss unlock(#1107) (#1108)
Browse files Browse the repository at this point in the history
Co-authored-by: yxw <[email protected]>
  • Loading branch information
ye-xiaowei and yxw authored Jun 12, 2024
1 parent 890033a commit f45e961
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ public void setError(final int errorCode) {
if (this.onError != null) {
this.onError.onError(this, this.data, errorCode);
}

} finally {
// Maybe destroyed in callback
if (!this.destroyed) {
// It may have been released during onError to avoid throwing an exception.
if (this.lock.isHeldByCurrentThread()) {
this.lock.unlock();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void run() {
Thread.sleep(1000);
this.id.unlock();
latch.await();
assertEquals(1000, cost.get(), 10);
assertEquals(1000, cost.get(), 20);
}

@Test
Expand Down

0 comments on commit f45e961

Please sign in to comment.