From a8e38b74e5fc6789676bf35a9b92594a230e3ad8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 13 Jul 2022 17:31:52 -0700 Subject: Avoid broadcast loops (fix #4894) --- src/main/java/org/traccar/broadcast/BroadcastInterface.java | 3 ++- src/main/java/org/traccar/broadcast/MulticastBroadcastService.java | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/traccar/broadcast') diff --git a/src/main/java/org/traccar/broadcast/BroadcastInterface.java b/src/main/java/org/traccar/broadcast/BroadcastInterface.java index 69e610dc6..dddba68b6 100644 --- a/src/main/java/org/traccar/broadcast/BroadcastInterface.java +++ b/src/main/java/org/traccar/broadcast/BroadcastInterface.java @@ -31,10 +31,11 @@ public interface BroadcastInterface { default void updateEvent(boolean local, long userId, Event event) { } - default void invalidateObject(Class clazz, long id) { + default void invalidateObject(boolean local, Class clazz, long id) { } default void invalidatePermission( + boolean local, Class clazz1, long id1, Class clazz2, long id2) { } diff --git a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java index be24989dd..3eafe07d3 100644 --- a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java +++ b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java @@ -98,7 +98,7 @@ public class MulticastBroadcastService implements BroadcastService { } @Override - public void invalidateObject(Class clazz, long id) { + public void invalidateObject(boolean local, Class clazz, long id) { BroadcastMessage message = new BroadcastMessage(); message.setChanges(Map.of(Permission.getKey(clazz), id)); sendMessage(message); @@ -106,6 +106,7 @@ public class MulticastBroadcastService implements BroadcastService { @Override public void invalidatePermission( + boolean local, Class clazz1, long id1, Class clazz2, long id2) { BroadcastMessage message = new BroadcastMessage(); @@ -137,10 +138,12 @@ public class MulticastBroadcastService implements BroadcastService { if (iterator.hasNext()) { var second = iterator.next(); listeners.forEach(listener -> listener.invalidatePermission( + false, Permission.getKeyClass(first.getKey()), first.getValue(), Permission.getKeyClass(second.getKey()), second.getValue())); } else { listeners.forEach(listener -> listener.invalidateObject( + false, Permission.getKeyClass(first.getKey()), first.getValue())); } } -- cgit v1.2.3