Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface TaskInterface<TResult> {
* @return true if the task completed (has a result, an error, or was cancelled). false otherwise.
*/
@Throws(InterruptedException::class)
public fun waitForCompletion(duration: Long, timeUnit: TimeUnit?): Boolean
public fun waitForCompletion(duration: Long, timeUnit: TimeUnit): Boolean

/** @return The result of the task, if set. null otherwise. */
public fun getResult(): TResult?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import android.net.Uri;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.facebook.common.logging.FLog;
Expand Down Expand Up @@ -506,8 +505,10 @@ public TaskInterface<Void> reload(String reason) {
if (task.isFaulted()) {
final Exception ex = task.getError();
if (mUseDevSupport) {
// NULLSAFE_FIXME[Parameter Not Nullable]
mDevSupportManager.handleException(ex);
} else {
// NULLSAFE_FIXME[Parameter Not Nullable]
mReactHostDelegate.handleInstanceException(ex);
}
return getOrCreateDestroyTask("Reload failed", ex);
Expand Down Expand Up @@ -567,18 +568,15 @@ private void loadNetworkResource(String url, InspectorNetworkRequestListener lis
* callback will run on a background thread.
* @return A task that completes when React Native gets destroyed.
*/
@NonNull
@Override
public TaskInterface<Void> destroy(
@NonNull String reason,
@Nullable Exception ex,
@NonNull Function1<? super Boolean, Unit> onDestroyFinished) {
String reason, @Nullable Exception ex, Function1<? super Boolean, Unit> onDestroyFinished) {
Task<Void> task = (Task<Void>) destroy(reason, ex);
return task.continueWith(
new Continuation<Void, Void>() {
@Nullable
@Override
public Void then(@NonNull Task<Void> task) throws Exception {
public Void then(Task<Void> task) throws Exception {
boolean instanceDestroyedSuccessfully = task.isCompleted() && !task.isFaulted();
onDestroyFinished.invoke(instanceDestroyedSuccessfully);
return null;
Expand Down Expand Up @@ -952,12 +950,12 @@ DefaultHardwareBackBtnHandler getDefaultBackButtonHandler() {
}

@Override
public void addBeforeDestroyListener(@NonNull Function0<Unit> onBeforeDestroy) {
public void addBeforeDestroyListener(Function0<Unit> onBeforeDestroy) {
mBeforeDestroyListeners.add(onBeforeDestroy);
}

@Override
public void removeBeforeDestroyListener(@NonNull Function0<Unit> onBeforeDestroy) {
public void removeBeforeDestroyListener(Function0<Unit> onBeforeDestroy) {
mBeforeDestroyListeners.remove(onBeforeDestroy);
}

Expand Down Expand Up @@ -993,14 +991,18 @@ private Task<Void> getOrCreateStartTask() {
if (task.isFaulted()) {
Exception ex = task.getError();
if (mUseDevSupport) {
// NULLSAFE_FIXME[Parameter Not Nullable]
mDevSupportManager.handleException(ex);
} else {
// NULLSAFE_FIXME[Parameter Not Nullable]
mReactHostDelegate.handleInstanceException(ex);
}
// Wait for destroy to finish
return getOrCreateDestroyTask(
// NULLSAFE_FIXME[Nullable Dereference]
"getOrCreateStartTask() failure: " + task.getError().getMessage(),
task.getError())
// NULLSAFE_FIXME[Parameter Not Nullable]
.continueWithTask(destroyTask -> Task.forError(task.getError()))
.makeVoid();
}
Expand Down Expand Up @@ -1083,6 +1085,7 @@ private Task<Void> callAfterGetOrCreateReactInstance(
.continueWith(
task -> {
if (task.isFaulted()) {
// NULLSAFE_FIXME[Parameter Not Nullable]
handleHostException(task.getError());
}
return null;
Expand Down Expand Up @@ -1202,6 +1205,7 @@ private Task<ReactInstance> getOrCreateReactInstanceTask() {
instance.initializeEagerTurboModules();

log(method, "Loading JS Bundle");
// NULLSAFE_FIXME[Parameter Not Nullable]
instance.loadJSBundle(bundleLoader);

log(
Expand All @@ -1225,8 +1229,11 @@ private Task<ReactInstance> getOrCreateReactInstanceTask() {

Continuation<CreationResult, ReactInstance> lifecycleUpdateTask =
task -> {
// NULLSAFE_FIXME[Nullable Dereference]
final ReactInstance reactInstance = task.getResult().mInstance;
// NULLSAFE_FIXME[Nullable Dereference]
final ReactContext reactContext = task.getResult().mContext;
// NULLSAFE_FIXME[Nullable Dereference]
final boolean isReloading = task.getResult().mIsReloading;
final boolean isManagerResumed =
mReactLifecycleStateManager.getLifecycleState() == LifecycleState.RESUMED;
Expand Down Expand Up @@ -1273,7 +1280,9 @@ private Task<ReactInstance> getOrCreateReactInstanceTask() {

creationTask.onSuccess(lifecycleUpdateTask, mUIExecutor);
return creationTask.onSuccess(
task -> task.getResult().mInstance, Task.IMMEDIATE_EXECUTOR);
// NULLSAFE_FIXME[Nullable Dereference]
task -> task.getResult().mInstance,
Task.IMMEDIATE_EXECUTOR);
});
}

Expand All @@ -1285,6 +1294,7 @@ private Task<JSBundleLoader> getJsBundleLoader() {
return isMetroRunning()
.onSuccessTask(
task -> {
// NULLSAFE_FIXME[Nullable Dereference]
boolean isMetroRunning = task.getResult();
if (isMetroRunning) {
// Since metro is running, fetch the JS bundle from the server
Expand Down Expand Up @@ -1409,6 +1419,7 @@ private ReactInstanceTaskUnwrapper createReactInstanceUnwrapper(
final String reasonLabel = tag + " reason: " + reason;
if (task.isFaulted()) {
final Exception ex = task.getError();
// NULLSAFE_FIXME[Nullable Dereference]
final String faultLabel = "Fault reason: " + ex.getMessage();
raiseSoftException(
method,
Expand Down Expand Up @@ -1588,6 +1599,7 @@ private Task<ReactInstance> getOrCreateReloadTask(String reason) {
raiseSoftException(
method,
"Error during reload. ReactInstance task faulted. Fault reason: "
// NULLSAFE_FIXME[Nullable Dereference]
+ fault.getMessage()
+ ". Reload reason: "
+ reason,
Expand Down Expand Up @@ -1761,6 +1773,7 @@ private Task<Void> getOrCreateDestroyTask(final String reason, @Nullable Excepti
raiseSoftException(
method,
"React destruction failed. ReactInstance task faulted. Fault reason: "
// NULLSAFE_FIXME[Nullable Dereference]
+ fault.getMessage()
+ ". Destroy reason: "
+ reason,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ package com.facebook.react.runtime.internal.bolts
*
* @see Task
*/
internal interface Continuation<TTaskResult, TContinuationResult> {
@Throws(Exception::class) fun then(task: Task<TTaskResult>): TContinuationResult?
public fun interface Continuation<TTaskResult, TContinuationResult> {
@Throws(Exception::class) public fun then(task: Task<TTaskResult>): TContinuationResult?
}
Loading