From 37e5f3b6ca3a1a1abfd756f098e313047b9720a5 Mon Sep 17 00:00:00 2001 From: ASCE1885 <380283392@qq.com> Date: Fri, 22 Jul 2016 09:16:50 -0700 Subject: [PATCH] fix mTimerIdsToTimers remove error Summary: In Timing.java, the key provided to the remove function of mTimerIdsToTimers is not correct, that may introduce bugs. Closes https://github.com/facebook/react-native/pull/8966 Differential Revision: D3605291 Pulled By: astreet fbshipit-source-id: 97563b6846e8f3f40d20b48b3852dd557c9932f3 --- .../java/com/facebook/react/modules/core/Timing.java | 5 ++--- .../react/views/art/ARTRenderableViewManager.java | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java index e95bf245e..2fc348e8d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java @@ -22,7 +22,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableArray; -import com.facebook.react.common.MapBuilder; import com.facebook.react.common.SystemClock; import com.facebook.react.devsupport.DevSupportManager; import com.facebook.react.uimanager.ReactChoreographer; @@ -105,7 +104,7 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl timer.mTargetTime = frameTimeMillis + timer.mInterval; mTimers.add(timer); } else { - mTimerIdsToTimers.remove(timer.mCallbackID); + mTimerIdsToTimers.remove(timer.mExecutorToken); } } } @@ -386,7 +385,7 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl return; } // We may have already called/removed it - mTimerIdsToTimers.remove(timerId); + mTimerIdsToTimers.remove(executorToken); mTimers.remove(timer); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTRenderableViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTRenderableViewManager.java index 44ba41ba6..5af6d1794 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTRenderableViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTRenderableViewManager.java @@ -52,11 +52,11 @@ public class ARTRenderableViewManager extends ViewManager @Override public ReactShadowNode createShadowNodeInstance() { - if (mClassName == CLASS_GROUP) { + if (CLASS_GROUP.equals(mClassName)) { return new ARTGroupShadowNode(); - } else if (mClassName == CLASS_SHAPE) { + } else if (CLASS_SHAPE.equals(mClassName)) { return new ARTShapeShadowNode(); - } else if (mClassName == CLASS_TEXT) { + } else if (CLASS_TEXT.equals(mClassName)) { return new ARTTextShadowNode(); } else { throw new IllegalStateException("Unexpected type " + mClassName); @@ -65,11 +65,11 @@ public class ARTRenderableViewManager extends ViewManager @Override public Class getShadowNodeClass() { - if (mClassName == CLASS_GROUP) { + if (CLASS_GROUP.equals(mClassName)) { return ARTGroupShadowNode.class; - } else if (mClassName == CLASS_SHAPE) { + } else if (CLASS_SHAPE.equals(mClassName)) { return ARTShapeShadowNode.class; - } else if (mClassName == CLASS_TEXT) { + } else if (CLASS_TEXT.equals(mClassName)) { return ARTTextShadowNode.class; } else { throw new IllegalStateException("Unexpected type " + mClassName);