Fix potential NPE in UIViewOperationQueue.

Summary:
We were noticing the following crash in our application, that was occurring fairly often, but still hard to reproduce:

```
12-12 10:37:35.342: E/AndroidRuntime(9064): FATAL EXCEPTION: main
12-12 10:37:35.342: E/AndroidRuntime(9064): Process: com.bloomberg.android.plus, PID: 9064
12-12 10:37:35.342: E/AndroidRuntime(9064): java.lang.NullPointerException: Attempt to invoke interface method 'void com.facebook.react.uimanager.UIViewOperationQueue$UIOperation.execute()' on a null object reference
12-12 10:37:35.342: E/AndroidRuntime(9064): 	at com.facebook.react.uimanager.UIViewOperationQueue$2.run(UIViewOperationQueue.java:782)
12-12 10:37:35.342: E/AndroidRuntime(9064): 	at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:829)
12-12 10:37:35.342: E/AndroidRuntime(9064): 	at com.facebook.react.uimanager.UIViewOperationQueue.access$1500(UIViewOperationQueue.java:44)
12-12 10:37:35.342: E/AndroidRuntime(9064): 	at com.facebook.react.uimanager.UIViewOperationQ
Closes https://github.com/facebook/react-native/pull/11428

Differential Revision: D4487841

Pulled By: astreet

fbshipit-source-id: ae49ef77967edea7514cbf40cb533c4b63fd34ae
This commit is contained in:
Mani Ghasemlou 2017-01-31 05:04:44 -08:00 committed by Facebook Github Bot
parent 29616e3122
commit cfb90284d6
1 changed files with 2 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import com.facebook.react.bridge.SoftAssertions;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.SoftAssertions;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
import com.facebook.systrace.Systrace; import com.facebook.systrace.Systrace;
@ -589,6 +590,7 @@ public class UIViewOperationQueue {
* subclass to support UIOperations not provided by UIViewOperationQueue. * subclass to support UIOperations not provided by UIViewOperationQueue.
*/ */
protected void enqueueUIOperation(UIOperation operation) { protected void enqueueUIOperation(UIOperation operation) {
SoftAssertions.assertNotNull(operation);
mOperations.add(operation); mOperations.add(operation);
} }