Fix NPE during search

Summary:
`getChilAt` can return `null` (see also line 671), probably when the UI changes during the inspection process. Added a null check that should protect against the failure reported in P501013941

Changelog: Fixed NPE during search in layout plugin (Android)

Reviewed By: lblasa

Differential Revision: D36369508

fbshipit-source-id: 1f066d1a73bdfe875d66f7200ded0d0776af8321
This commit is contained in:
Michel Weststrate
2022-05-13 07:08:52 -07:00
committed by Facebook GitHub Bot
parent e51e95af2e
commit 18d64f9631

View File

@@ -624,6 +624,9 @@ public class InspectorFlipperPlugin implements FlipperPlugin {
} }
public SearchResultNode searchTree(String query, Object obj, boolean axEnabled) throws Exception { public SearchResultNode searchTree(String query, Object obj, boolean axEnabled) throws Exception {
if (obj == null) {
return null;
}
final NodeDescriptor descriptor = descriptorForObject(obj); final NodeDescriptor descriptor = descriptorForObject(obj);
List<SearchResultNode> childTrees = null; List<SearchResultNode> childTrees = null;
boolean isMatch = descriptor.matches(query, obj); boolean isMatch = descriptor.matches(query, obj);