Skip to content

Commit

Permalink
(fix) CountDownLatch is best placed into finally statement to avoid t…
Browse files Browse the repository at this point in the history
…hread blocking when calls Closure#run(status) throw an exception (sofastack#713)

Co-authored-by: penglong <[email protected]>
  • Loading branch information
XiaoyiPeng and penglong authored Nov 16, 2021
1 parent e8b3976 commit 4b13f9b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public JoinableClosure(Closure closure) {

@Override
public void run(final Status status) {
this.closure.run(status);
latch.countDown();
try {
this.closure.run(status);
} finally {
latch.countDown();
}
}

public void join() throws InterruptedException {
Expand Down

0 comments on commit 4b13f9b

Please sign in to comment.