diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-13 17:31:52 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-13 17:31:52 -0700 |
commit | a8e38b74e5fc6789676bf35a9b92594a230e3ad8 (patch) | |
tree | eed89969aecd7c9652f8640742530c96a4fc40b3 /src/main/java/org/traccar/session/cache | |
parent | 33733f835e88a62c4a5259ab330723b88037adf1 (diff) | |
download | trackermap-server-a8e38b74e5fc6789676bf35a9b92594a230e3ad8.tar.gz trackermap-server-a8e38b74e5fc6789676bf35a9b92594a230e3ad8.tar.bz2 trackermap-server-a8e38b74e5fc6789676bf35a9b92594a230e3ad8.zip |
Avoid broadcast loops (fix #4894)
Diffstat (limited to 'src/main/java/org/traccar/session/cache')
-rw-r--r-- | src/main/java/org/traccar/session/cache/CacheManager.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/session/cache/CacheManager.java b/src/main/java/org/traccar/session/cache/CacheManager.java index 4e99161dd..58eb95327 100644 --- a/src/main/java/org/traccar/session/cache/CacheManager.java +++ b/src/main/java/org/traccar/session/cache/CacheManager.java @@ -188,12 +188,12 @@ public class CacheManager implements BroadcastInterface { } @Override - public void invalidateObject(Class<? extends BaseModel> clazz, long id) { + public void invalidateObject(boolean local, Class<? extends BaseModel> clazz, long id) { try { var object = storage.getObject(clazz, new Request( new Columns.All(), new Condition.Equals("id", "id", id))); if (object != null) { - updateOrInvalidate(object); + updateOrInvalidate(local, object); } else { invalidate(clazz, id); } @@ -202,8 +202,10 @@ public class CacheManager implements BroadcastInterface { } } - public <T extends BaseModel> void updateOrInvalidate(T object) throws StorageException { - broadcastService.invalidateObject(object.getClass(), object.getId()); + public <T extends BaseModel> void updateOrInvalidate(boolean local, T object) throws StorageException { + if (local) { + broadcastService.invalidateObject(true, object.getClass(), object.getId()); + } boolean invalidate = false; var before = getObject(object.getClass(), object.getId()); @@ -232,9 +234,12 @@ public class CacheManager implements BroadcastInterface { @Override public void invalidatePermission( + boolean local, Class<? extends BaseModel> clazz1, long id1, Class<? extends BaseModel> clazz2, long id2) { - broadcastService.invalidatePermission(clazz1, id1, clazz2, id2); + if (local) { + broadcastService.invalidatePermission(true, clazz1, id1, clazz2, id2); + } try { invalidate(new CacheKey(clazz1, id1), new CacheKey(clazz2, id2)); |