Skip to content

Commit

Permalink
Fix up gated listener
Browse files Browse the repository at this point in the history
Signed-off-by: Bukhtawar Khan <[email protected]>
  • Loading branch information
Bukhtawar committed Jul 11, 2023
1 parent dbc4f72 commit 1e3a6f1
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ public void afterRefresh(boolean didRefresh) throws IOException {
});
}

private void handleDelegate(Runnable delegate) throws IOException {
private void handleDelegate(Runnable delegate) {
assert Thread.holdsLock(this);
try {
if (closed.get() == false) {
if (closed.get() == false) {
try {
if (semaphore.tryAcquire(1, 0, TimeUnit.SECONDS)) {
try {
delegate.run();
} finally {
semaphore.release(1);
}
} else {
// this should never happen, if it does something is deeply wrong
throw new TimeoutException("failed to obtain permit but operations are not delayed");
}
} else {
// this should never happen, if it does something is deeply wrong
throw new TimeoutException("failed to obtain permit but operations are not delayed");
} catch(InterruptedException | TimeoutException e){
throw new RuntimeException("Failed to handle delegate due to ", e);
}
} catch (InterruptedException | TimeoutException e) {
throw new RuntimeException("Failed to handle delegate due to ", e);
}
}

Expand Down

0 comments on commit 1e3a6f1

Please sign in to comment.