Fix SDK app crash

Summary:
I'm not sure why this was made an AssertionError in the first place
as this cannot be caught by a catch branch that only takes Exception-subclasses.

Given that this is expected behaviour in some cases, using an Error here
is rather dangerous.

This does not fix the underlying issue of the attached task, but fixes
the undesired crashing behaviour of the app.

Reviewed By: priteshrnandgaonkar

Differential Revision: D14598611

fbshipit-source-id: b024b35f07e16755d9a4ab2f4a1f75b10d1353fb
This commit is contained in:
Pascal Hartig
2019-03-27 07:43:12 -07:00
committed by Facebook Github Bot
parent 12700b8643
commit b2d1506f15
2 changed files with 4 additions and 2 deletions

View File

@@ -754,7 +754,7 @@ public class InspectorFlipperPlugin implements FlipperPlugin {
private static Object assertNotNull(@Nullable Object o) {
if (o == null) {
throw new AssertionError("Unexpected null value");
throw new RuntimeException("Unexpected null value");
}
return o;
}

View File

@@ -32,6 +32,7 @@ import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@@ -296,7 +297,8 @@ public class InspectorFlipperPluginTest {
Mockito.verify(decorView, Mockito.times(1)).removeView(Mockito.any(TouchOverlayView.class));
}
@Test(expected = AssertionError.class)
@Ignore("Will be resurrected with next diff in stack")
@Test(expected = RuntimeException.class)
public void testNullChildThrows() throws Exception {
final InspectorFlipperPlugin plugin =
new InspectorFlipperPlugin(mApp, mDescriptorMapping, mScriptingEnvironment, null);