diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java index e5783e3c5..16fb9ae4a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEventCoalescingKeyHelper.java @@ -81,6 +81,10 @@ public class TouchEventCoalescingKeyHelper { * Stops tracking a new coalescing key corresponding to the gesture with this down time. */ public static void removeCoalescingKey(long downTime) { + int currentValue = sDownTimeToCoalescingKey.get((int) downTime, -1); + if (currentValue == -1) { + throw new RuntimeException("Tried to remove non-existent cookie"); + } sDownTimeToCoalescingKey.delete((int) downTime); } } diff --git a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java index 2eb7f5ed8..679ce6edd 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java @@ -162,7 +162,7 @@ public class RootViewTest { ArgumentCaptor.forClass(JavaOnlyArray.class); rootView.onTouchEvent( - MotionEvent.obtain(50, ts, MotionEvent.ACTION_UP, 0, 0, 0)); + MotionEvent.obtain(100, ts, MotionEvent.ACTION_UP, 0, 0, 0)); verify(eventDispatcher).dispatchEvent(upEventCaptor.capture()); verifyNoMoreInteractions(eventDispatcher);