Skip to content

Commit

Permalink
Fix race condition in DefaultEventHandle (#3618)
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
  • Loading branch information
kkondaka and Krishna Kondaka authored Nov 9, 2023
1 parent 621de7b commit d3acfa7
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ public Instant getExternalOriginationTime() {

@Override
public void release(boolean result) {
for (final BiConsumer<EventHandle, Boolean> consumer: releaseConsumers) {
consumer.accept(this, result);
synchronized (releaseConsumers) {
for (final BiConsumer<EventHandle, Boolean> consumer: releaseConsumers) {
consumer.accept(this, result);
}
}
AcknowledgementSet acknowledgementSet = getAcknowledgementSet();
if (acknowledgementSet != null) {
Expand All @@ -67,6 +69,8 @@ public void release(boolean result) {

@Override
public void onRelease(BiConsumer<EventHandle, Boolean> releaseConsumer) {
releaseConsumers.add(releaseConsumer);
synchronized (releaseConsumers) {
releaseConsumers.add(releaseConsumer);
}
}
}

0 comments on commit d3acfa7

Please sign in to comment.