Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

fix ConcurrentModificationException #2255

Merged
merged 1 commit into from
Mar 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class WXServiceManager {

private static Map<String, WXJSService> sInstanceJSServiceMap = new HashMap<>();
private static volatile ConcurrentHashMap<String, WXJSService> sInstanceJSServiceMap = new ConcurrentHashMap<>();

public static boolean registerService(String name, String serviceScript, Map<String, Object> options) {
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(serviceScript)) return false;
Expand Down Expand Up @@ -83,14 +84,16 @@ public static WXJSService getService(String serviceName) {
}

public static void reload() {
WXBridgeManager.getInstance().post(new Runnable() {
@Override
public void run() {
for (Map.Entry<String, WXJSService> entry : sInstanceJSServiceMap.entrySet()) {
WXJSService service = entry.getValue();
registerService(service.getName(), service.getScript(), service.getOptions());
if(sInstanceJSServiceMap != null && sInstanceJSServiceMap.size() > 0) {
WXBridgeManager.getInstance().post(new Runnable() {
@Override
public void run() {
for (Map.Entry<String, WXJSService> entry : sInstanceJSServiceMap.entrySet()) {
WXJSService service = entry.getValue();
registerService(service.getName(), service.getScript(), service.getOptions());
}
}
}
});
});
}
}
}