Commit 7c849abf29dd848ee04c61f0074ae1d84705a9cf

Authored by Awen
1 parent 1c32be45

修复集合遍历删除元素的java.util.ConcurrentModificationException 异常问题

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
@@ -63,7 +63,7 @@ public class ZLMHttpHookSubscribe { @@ -63,7 +63,7 @@ public class ZLMHttpHookSubscribe {
63 } 63 }
64 64
65 } 65 }
66 - if (result) { 66 + if (null != result && result) {
67 event = eventMap.get(key); 67 event = eventMap.get(key);
68 } 68 }
69 } 69 }
@@ -75,7 +75,10 @@ public class ZLMHttpHookSubscribe { @@ -75,7 +75,10 @@ public class ZLMHttpHookSubscribe {
75 if (eventMap == null) { 75 if (eventMap == null) {
76 return; 76 return;
77 } 77 }
78 - for (JSONObject key : eventMap.keySet()) { 78 + Iterator<Map.Entry<JSONObject, Event>> iterator = eventMap.entrySet().iterator();
  79 + while (iterator.hasNext()){
  80 + Map.Entry<JSONObject, Event> next = iterator.next();
  81 + JSONObject key = next.getKey();
79 Boolean result = null; 82 Boolean result = null;
80 for (String s : key.keySet()) { 83 for (String s : key.keySet()) {
81 if (result == null) { 84 if (result == null) {
@@ -85,8 +88,8 @@ public class ZLMHttpHookSubscribe { @@ -85,8 +88,8 @@ public class ZLMHttpHookSubscribe {
85 } 88 }
86 89
87 } 90 }
88 - if (result) {  
89 - eventMap.remove(key); 91 + if (null != result && result){
  92 + iterator.remove();
90 } 93 }
91 } 94 }
92 } 95 }