Skip to content

Commit

Permalink
Unblock the hooks execution (#11359)
Browse files Browse the repository at this point in the history
close #11231

Changelog:
- fix: do not block during the hooks execution
  • Loading branch information
4e6 authored Oct 20, 2024
1 parent c6ec5c5 commit 1fbaeaa
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ public void add(Runnable hook) {

@Override
public void run() {
Runnable[] hooksToRun;
synchronized (hooks) {
for (Runnable hook : hooks) {
try {
hook.run();
} catch (Exception e) {
logger.error("Failed to run execution hook.", e);
hooksToRun = hooks.toArray(new Runnable[0]);
}

for (Runnable hook : hooksToRun) {
try {
hook.run();
} catch (Exception e) {
logger.error("Failed to run execution hook.", e);
} finally {
synchronized (hooks) {
hooks.remove(hook);
}
}
hooks.clear();
}
}
}

0 comments on commit 1fbaeaa

Please sign in to comment.