Skip to content

Commit d765565

Browse files
dulmandakhfacebook-github-bot
authored andcommitted
fix ReadableArray annotations (#30122)
Summary: Fix ReadableArray annotations, because these methods throw ArrayIndexOutOfBoundsException instead of null if index is not found. ## Changelog [Android] [Changed] - fix ReadableArray null annotations. Possibly breaking change for Kotlin apps. Pull Request resolved: #30122 Test Plan: RNTester app builds and runs as expected, and show correct type in when used with Kotlin code. Reviewed By: JoshuaGross Differential Revision: D24164326 Pulled By: fkgozali fbshipit-source-id: 0c3f8fa9accbd32cc71c50befe9330e5201643f6
1 parent 4d4992c commit d765565

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package com.facebook.react.bridge;
99

1010
import androidx.annotation.NonNull;
11-
import androidx.annotation.Nullable;
1211
import java.util.ArrayList;
1312

1413
/**
@@ -27,13 +26,13 @@ public interface ReadableArray {
2726

2827
int getInt(int index);
2928

30-
@Nullable
29+
@NonNull
3130
String getString(int index);
3231

33-
@Nullable
32+
@NonNull
3433
ReadableArray getArray(int index);
3534

36-
@Nullable
35+
@NonNull
3736
ReadableMap getMap(int index);
3837

3938
@NonNull

ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ public int getInt(int index) {
9898
}
9999

100100
@Override
101-
public @Nullable String getString(int index) {
101+
public @NonNull String getString(int index) {
102102
return (String) getLocalArray()[index];
103103
}
104104

105105
@Override
106-
public @Nullable ReadableNativeArray getArray(int index) {
106+
public @NonNull ReadableNativeArray getArray(int index) {
107107
return (ReadableNativeArray) getLocalArray()[index];
108108
}
109109

110110
@Override
111-
public @Nullable ReadableNativeMap getMap(int index) {
111+
public @NonNull ReadableNativeMap getMap(int index) {
112112
return (ReadableNativeMap) getLocalArray()[index];
113113
}
114114

0 commit comments

Comments
 (0)