Skip to content

Commit

Permalink
Fix event ordering for item events (#3628)
Browse files Browse the repository at this point in the history
Posting the `ItemAddedEvent` after notifying the listeners results in `ItemStateUpdated/ChangedEvents` before the `ItemAddedEvent` because the state could be altered by persistence services. This is at least unexpected and can be fixed by swapping the order.

Signed-off-by: Jan N. Klug <github@klug.nrw>
  • Loading branch information
J-N-K authored May 25, 2023
1 parent a8a5e86 commit cd06e6d
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,20 @@ public Collection<Item> getItemsByTagAndType(String type, String... tags) {

@Override
protected void notifyListenersAboutAddedElement(Item element) {
super.notifyListenersAboutAddedElement(element);
postEvent(ItemEventFactory.createAddedEvent(element));
super.notifyListenersAboutAddedElement(element);
}

@Override
protected void notifyListenersAboutRemovedElement(Item element) {
super.notifyListenersAboutRemovedElement(element);
postEvent(ItemEventFactory.createRemovedEvent(element));
super.notifyListenersAboutRemovedElement(element);
}

@Override
protected void notifyListenersAboutUpdatedElement(Item oldElement, Item element) {
super.notifyListenersAboutUpdatedElement(oldElement, element);
postEvent(ItemEventFactory.createUpdateEvent(element, oldElement));
super.notifyListenersAboutUpdatedElement(oldElement, element);
}

@Override
Expand Down

0 comments on commit cd06e6d

Please sign in to comment.