From 4dcc7df555e0027adcea89aa2590eb56605398c2 Mon Sep 17 00:00:00 2001
From: xiaoxie <hotcoffie@163.com>
Date: 星期四, 21 四月 2022 10:03:21 +0800
Subject: [PATCH] 修复前端一处v-for没有key的警告
---
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
index 3505225..8a62bea 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -39,12 +40,7 @@
private Map<HookType, Map<JSONObject, ZLMHttpHookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>();
public void addSubscribe(HookType type, JSONObject hookResponse, ZLMHttpHookSubscribe.Event event) {
- Map<JSONObject, Event> eventMap = allSubscribes.get(type);
- if (eventMap == null) {
- eventMap = new HashMap<JSONObject, Event>();
- allSubscribes.put(type,eventMap);
- }
- eventMap.put(hookResponse, event);
+ allSubscribes.computeIfAbsent(type, k -> new ConcurrentHashMap<>()).put(hookResponse, event);
}
public ZLMHttpHookSubscribe.Event getSubscribe(HookType type, JSONObject hookResponse) {
@@ -81,7 +77,8 @@
Set<Map.Entry<JSONObject, Event>> entries = eventMap.entrySet();
if (entries.size() > 0) {
- for (Map.Entry<JSONObject, Event> entry : entries) {
+ List<Map.Entry<JSONObject, ZLMHttpHookSubscribe.Event>> entriesToRemove = new ArrayList<>();
+ for (Map.Entry<JSONObject, ZLMHttpHookSubscribe.Event> entry : entries) {
JSONObject key = entry.getKey();
Boolean result = null;
for (String s : key.keySet()) {
@@ -93,9 +90,16 @@
}
}
if (null != result && result){
+ entriesToRemove.add(entry);
+ }
+ }
+
+ if (!CollectionUtils.isEmpty(entriesToRemove)) {
+ for (Map.Entry<JSONObject, ZLMHttpHookSubscribe.Event> entry : entriesToRemove) {
entries.remove(entry);
}
}
+
}
}
--
Gitblit v1.8.0