Commit fd296d1a6acccbe9f3a72623719bf7101725f4e9
Committed by
GitHub
Merge pull request #93 from yu1183688986/wvp-28181-2.0
修复集合遍历删除元素的java.util.ConcurrentModificationException 异常问题
Showing
1 changed file
with
7 additions
and
4 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
| ... | ... | @@ -63,7 +63,7 @@ public class ZLMHttpHookSubscribe { |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | } |
| 66 | - if (result) { | |
| 66 | + if (null != result && result) { | |
| 67 | 67 | event = eventMap.get(key); |
| 68 | 68 | } |
| 69 | 69 | } |
| ... | ... | @@ -75,7 +75,10 @@ public class ZLMHttpHookSubscribe { |
| 75 | 75 | if (eventMap == null) { |
| 76 | 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 | 82 | Boolean result = null; |
| 80 | 83 | for (String s : key.keySet()) { |
| 81 | 84 | if (result == null) { |
| ... | ... | @@ -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 | } | ... | ... |