Skip to content

Commit aabdf55

Browse files
Ron Edelsteinmeta-codesync[bot]
authored andcommitted
Fix infinite recursion in ReactPropAnnotationSetterSpecTest (#55662)
Summary: Pull Request resolved: #55662 Fix infinite recursion bugs in `ReactPropAnnotationSetterSpecTest.kt`: - `createShadowNodeInstance()` (line 25): Method calls itself recursively instead of creating a shadow node instance. Fixed to return `ReactShadowNodeImpl()`, which is the concrete implementation of `ReactShadowNode`. - `createViewInstance(reactContext)` (line 30): Method calls itself recursively instead of creating a view instance. Fixed to return `View(reactContext)`, which creates a basic Android View. Both methods are in an abstract inner `BaseViewManager` test class used to satisfy the `ViewManager` abstract contract. The test class is only used to verify `ReactProp` annotation validation, so these methods just need to return valid instances. Detected by InfiniteRecursion lint detector (D93897169). Changelog: [Internal] - Reviewed By: cortinico Differential Revision: D93927939 fbshipit-source-id: b971f1fbc9e0c216e2cb9db642f34a6cbf38394a
1 parent 352d73b commit aabdf55

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ class ReactPropAnnotationSetterSpecTest {
2222
private abstract inner class BaseViewManager : ViewManager<View, ReactShadowNode<*>>() {
2323
override fun getName(): String = "IgnoredName"
2424

25-
override fun createShadowNodeInstance(): ReactShadowNode<*> = createShadowNodeInstance()
25+
override fun createShadowNodeInstance(): ReactShadowNode<*> = ReactShadowNodeImpl()
2626

2727
override fun getShadowNodeClass(): Class<out ReactShadowNode<*>> = ReactShadowNode::class.java
2828

29-
override fun createViewInstance(reactContext: ThemedReactContext): View =
30-
createViewInstance(reactContext)
29+
override fun createViewInstance(reactContext: ThemedReactContext): View = View(reactContext)
3130

3231
override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? = null
3332

0 commit comments

Comments
 (0)