Skip to content

Commit

Permalink
修复 ServiceManager 的 register 的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
keepactive committed Dec 16, 2020
1 parent 33005ef commit bd8b37b
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,13 @@ public static <T> void register(@NonNull Class<T> tClass, @NonNull String name,
Utils.checkNullPointer(name, "name");
Utils.checkNullPointer(callable, "callable");
synchronized (serviceMap) {
unregister(tClass);
HashMap<String, Callable<?>> implServiceMap = serviceMap.get(tClass);
if (implServiceMap == null) {
implServiceMap = new HashMap<>();
serviceMap.put(tClass, implServiceMap);
}
if (Component.isDebug()) {
if (implServiceMap.containsKey(name)) {
throw new RuntimeException("the key of " + name + " is exist");
}
if (implServiceMap.containsKey(name)) {
throw new RuntimeException("the key of " + name + " is exist");
}
implServiceMap.put(name, callable);
}
Expand Down

0 comments on commit bd8b37b

Please sign in to comment.