Skip to content

Commit

Permalink
fix(android): Avoid ConcurrentModificationException on notifyListeners (
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Oct 13, 2021
1 parent 3414577 commit b82bfe0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Expand Up @@ -29,6 +29,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.json.JSONException;

/**
Expand Down Expand Up @@ -668,7 +669,8 @@ protected void notifyListeners(String eventName, JSObject data, boolean retainUn
return;
}

for (PluginCall call : listeners) {
CopyOnWriteArrayList<PluginCall> listenersCopy = new CopyOnWriteArrayList(listeners);
for (PluginCall call : listenersCopy) {
call.resolve(data);
}
}
Expand Down

0 comments on commit b82bfe0

Please sign in to comment.