Summary:public

== cause ==

The follow block is error-prone.

```
 for (ReactInstanceEventListener listener : mReactInstanceEventListeners) {
   listener.onReactContextInitialized(reactContext);
 }
```

Because calling `listener.onReactContextInitialized` may have side-effect that
removes the `listener` from `mReactInstanceEventListeners`, thus break the
iteration with exception.

I've found at least one place that has such side-effect
diffusion/FA/browse/master/java/com/facebook/fbreact/autoupdater/AutoUpdaterScheduler.java;9c09e5bbd411e093fb2ad022ee5d0ea473e9ebfe$32

The right way to fix this is to be side-effect proof.

Reviewed By: zahanm

Differential Revision: D2943494

fb-gh-sync-id: ba848ea736c5d2d0b8ef0b5a899603d734781361
shipit-source-id: ba848ea736c5d2d0b8ef0b5a899603d734781361
This commit is contained in:
Hedger Wang 2016-02-17 02:28:29 -08:00 коммит произвёл facebook-github-bot-4
Родитель d8e07eab95
Коммит 011dc8904f
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -663,7 +663,11 @@ import static com.facebook.react.bridge.ReactMarkerConstants.*;
attachMeasuredRootViewToInstance(rootView, catalystInstance);
}
for (ReactInstanceEventListener listener : mReactInstanceEventListeners) {
ReactInstanceEventListener[] listeners =
new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
listeners = mReactInstanceEventListeners.toArray(listeners);
for (ReactInstanceEventListener listener : listeners) {
listener.onReactContextInitialized(reactContext);
}
}