diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 31fe7a528..01ceb8e8b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -16,18 +16,17 @@ import java.io.StringWriter; import java.util.Collection; import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import com.facebook.common.logging.FLog; +import com.facebook.infer.annotation.Assertions; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.queue.CatalystQueueConfiguration; import com.facebook.react.bridge.queue.CatalystQueueConfigurationImpl; import com.facebook.react.bridge.queue.CatalystQueueConfigurationSpec; import com.facebook.react.bridge.queue.QueueThreadExceptionHandler; -import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.common.ReactConstants; import com.facebook.react.common.annotations.VisibleForTesting; -import com.facebook.infer.annotation.Assertions; import com.facebook.systrace.Systrace; import com.facebook.systrace.TraceListener; @@ -41,9 +40,6 @@ import com.fasterxml.jackson.core.JsonGenerator; @DoNotStrip public class CatalystInstanceImpl implements CatalystInstance { - private static final int BRIDGE_SETUP_TIMEOUT_MS = 30000; - private static final int LOAD_JS_BUNDLE_TIMEOUT_MS = 30000; - private static final AtomicInteger sNextInstanceIdForTrace = new AtomicInteger(1); // Access from any thread @@ -96,7 +92,7 @@ public class CatalystInstanceImpl implements CatalystInstance { Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); } } - }).get(BRIDGE_SETUP_TIMEOUT_MS, TimeUnit.MILLISECONDS); + }).get(); } catch (Exception t) { throw new RuntimeException("Failed to initialize bridge", t); } @@ -159,7 +155,7 @@ public class CatalystInstanceImpl implements CatalystInstance { return true; } - }).get(LOAD_JS_BUNDLE_TIMEOUT_MS, TimeUnit.MILLISECONDS); + }).get(); } catch (Exception t) { throw new RuntimeException(t); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/futures/SimpleSettableFuture.java b/ReactAndroid/src/main/java/com/facebook/react/common/futures/SimpleSettableFuture.java index b2809ae37..063279ad3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/futures/SimpleSettableFuture.java +++ b/ReactAndroid/src/main/java/com/facebook/react/common/futures/SimpleSettableFuture.java @@ -37,8 +37,8 @@ public class SimpleSettableFuture implements Future { } /** - * Sets the eception. If another thread has called {@link #get}, they will immediately receive the - * exception. set or setException must only be called once. + * Sets the exception. If another thread has called {@link #get}, they will immediately receive + * the exception. set or setException must only be called once. */ public void setException(Exception exception) { checkNotSet(); @@ -61,10 +61,14 @@ public class SimpleSettableFuture implements Future { return mReadyLatch.getCount() == 0; } - @Deprecated @Override - public T get() throws InterruptedException, ExecutionException { - throw new UnsupportedOperationException("Must use a timeout"); + public @Nullable T get() throws InterruptedException, ExecutionException { + mReadyLatch.await(); + if (mException != null) { + throw new ExecutionException(mException); + } + + return mResult; } /** @@ -77,12 +81,8 @@ public class SimpleSettableFuture implements Future { @Override public @Nullable T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - try { - if (!mReadyLatch.await(timeout, unit)) { - throw new TimeoutException("Timed out waiting for result"); - } - } catch (InterruptedException e) { - throw new RuntimeException(e); + if (!mReadyLatch.await(timeout, unit)) { + throw new TimeoutException("Timed out waiting for result"); } if (mException != null) { throw new ExecutionException(mException);