Skip to content

Commit

Permalink
Change where MergedListener validates and sets notificationStep, so w…
Browse files Browse the repository at this point in the history
…e don't report spurious double-notifies if a notification runs after destroy caused a prior notification to be skipped
  • Loading branch information
rcaudy committed Nov 23, 2024
1 parent 40bcc8a commit f28e9e2
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@ public void run() {
+ System.identityHashCode(MergedListener.this) + ": queuedNotificationStep="
+ lastEnqueuedStep + ", step=" + currentStep);
}
synchronized (MergedListener.this) {
if (notificationStep == lastEnqueuedStep) {
// noinspection ConstantConditions
throw Assert.statementNeverExecuted("Multiple notifications in the same step: listener="
+ System.identityHashCode(MergedListener.this) + ", queuedNotificationStep="
+ lastEnqueuedStep);
}
notificationStep = lastEnqueuedStep;
}
// Retain a reference during update processing to prevent interference from concurrent destroys
if (!tryRetainReference()) {
// This listener is no longer live, there's no point to doing any work for this notification
Expand Down Expand Up @@ -384,15 +393,6 @@ private void runInternal(final long currentStep) {
entry.onUpdateStart(added, removed, modified, shifted);
}
try {
synchronized (MergedListener.this) {
if (notificationStep == lastEnqueuedStep) {
// noinspection ConstantConditions
throw Assert.statementNeverExecuted("Multiple notifications in the same step: listener="
+ System.identityHashCode(MergedListener.this) + ", queuedNotificationStep="
+ lastEnqueuedStep);
}
notificationStep = lastEnqueuedStep;
}
process();
getUpdateGraph().logDependencies()
.append("MergedListener has completed execution ")
Expand Down

0 comments on commit f28e9e2

Please sign in to comment.