mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Handle null connections (#37626)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37626 `inspector_->connect` can return `null` when the connection fails. Check for `null` and raise an exception (preventing a later crash when the `null` connection is used). Changelog: [Internal] Reviewed By: voideanvalue Differential Revision: D46126080 fbshipit-source-id: 42e08687b4d425dd87642cf6b61f675e77c738ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7fb9e4f46c
commit
3f0caedd4d
+5
-1
@@ -34,7 +34,11 @@ public class Inspector {
|
||||
|
||||
public static LocalConnection connect(int pageId, RemoteConnection remote) {
|
||||
try {
|
||||
return instance().connectNative(pageId, remote);
|
||||
final LocalConnection local = instance().connectNative(pageId, remote);
|
||||
if (local == null) {
|
||||
throw new IllegalStateException("Can't open failed connection");
|
||||
}
|
||||
return local;
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
FLog.e(ReactConstants.TAG, "Inspector doesn't work in open source yet", e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -95,7 +95,9 @@ jni::local_ref<JLocalConnection::javaobject> JInspector::connect(
|
||||
jni::alias_ref<JRemoteConnection::javaobject> remote) {
|
||||
auto localConnection = inspector_->connect(
|
||||
pageId, std::make_unique<RemoteConnection>(std::move(remote)));
|
||||
return JLocalConnection::newObjectCxxArgs(std::move(localConnection));
|
||||
return localConnection
|
||||
? JLocalConnection::newObjectCxxArgs(std::move(localConnection))
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void JInspector::registerNatives() {
|
||||
|
||||
Reference in New Issue
Block a user