diff --git a/src/main/java/org/cryptomator/event/NotificationManager.java b/src/main/java/org/cryptomator/event/NotificationManager.java index cdb9d99a8..7cd5ae1e1 100644 --- a/src/main/java/org/cryptomator/event/NotificationManager.java +++ b/src/main/java/org/cryptomator/event/NotificationManager.java @@ -73,7 +73,9 @@ public class NotificationManager { * @param target list where the filesystem events are copied to * @return {@code true}, if elements were copied */ - public boolean addTo(List target) { + public boolean appendToAndClear(List target) { + //it is not clear, if addAll iterates thread-safe over the pendingEvents + //hence we synchronize moving (copy then clear) and adding-single-element operations synchronized (this) { var result = target.addAll(pendingEvents); pendingEvents.clear(); diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxNotificationManager.java b/src/main/java/org/cryptomator/ui/fxapp/FxNotificationManager.java index 7be86fc50..c1100a2f4 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxNotificationManager.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxNotificationManager.java @@ -43,7 +43,7 @@ public class FxNotificationManager { private void checkForPendingNotifications() { Platform.runLater(() -> { - if (notificationManager.addTo(eventsRequiringNotification)) { + if (notificationManager.appendToAndClear(eventsRequiringNotification)) { applicationWindows.showNotification(); } });