From b0e494b842448568b6c20c9fbc7baa1df106b595 Mon Sep 17 00:00:00 2001 From: 朱俊杰 <502612493@qq.com> Date: 星期二, 29 三月 2022 17:31:41 +0800 Subject: [PATCH] 2个小bug --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 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 c8cca53..3505225 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 @@ -31,6 +31,7 @@ on_server_keepalive } + @FunctionalInterface public interface Event{ void response(MediaServerItem mediaServerItem, JSONObject response); } @@ -77,21 +78,23 @@ if (eventMap == null) { return; } - Iterator<Map.Entry<JSONObject, Event>> iterator = eventMap.entrySet().iterator(); - while (iterator.hasNext()){ - Map.Entry<JSONObject, Event> next = iterator.next(); - JSONObject key = next.getKey(); - Boolean result = null; - for (String s : key.keySet()) { - if (result == null) { - result = key.getString(s).equals(hookResponse.getString(s)); - }else { - if (key.getString(s) == null) continue; - result = result && key.getString(s).equals(hookResponse.getString(s)); + + Set<Map.Entry<JSONObject, Event>> entries = eventMap.entrySet(); + if (entries.size() > 0) { + for (Map.Entry<JSONObject, Event> entry : entries) { + JSONObject key = entry.getKey(); + Boolean result = null; + for (String s : key.keySet()) { + if (result == null) { + result = key.getString(s).equals(hookResponse.getString(s)); + }else { + if (key.getString(s) == null) continue; + result = result && key.getString(s).equals(hookResponse.getString(s)); + } } - } - if (null != result && result){ - iterator.remove(); + if (null != result && result){ + entries.remove(entry); + } } } } -- Gitblit v1.8.0