Skip to content

Commit

Permalink
fix ReadableArray annotations (#30122)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dulmandakh authored and facebook-github-bot committed Oct 7, 2020
1 parent 4d4992c commit d765565
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.facebook.react.bridge;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;

/**
Expand All @@ -27,13 +26,13 @@ public interface ReadableArray {

int getInt(int index);

@Nullable
@NonNull
String getString(int index);

@Nullable
@NonNull
ReadableArray getArray(int index);

@Nullable
@NonNull
ReadableMap getMap(int index);

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ public int getInt(int index) {
}

@Override
public @Nullable String getString(int index) {
public @NonNull String getString(int index) {
return (String) getLocalArray()[index];
}

@Override
public @Nullable ReadableNativeArray getArray(int index) {
public @NonNull ReadableNativeArray getArray(int index) {
return (ReadableNativeArray) getLocalArray()[index];
}

@Override
public @Nullable ReadableNativeMap getMap(int index) {
public @NonNull ReadableNativeMap getMap(int index) {
return (ReadableNativeMap) getLocalArray()[index];
}

Expand Down

0 comments on commit d765565

Please sign in to comment.