litho icon indicating copy to clipboard operation
litho copied to clipboard

NPE fix for concurrency issues.

Open gogeta95 opened this issue 5 years ago • 1 comments

Summary

We are using this library in a project and get NPEs on a specific configuration because of concurrency issues. This catches the NPE and defaults to false.

Changelog

  • Fix NPEs in a rare scenario

Test Plan

N/A

gogeta95 avatar Aug 14 '20 10:08 gogeta95

If racing is a problem that causes NPE when accessing LayoutState then I believe this change could be better done as

if (mLayoutStateContext == null) {
 LayoutState layoutState = mLayoutStateContext.getLayoutState();
 return layoutState != null && layoutState.isCreateLayoutInProgress();
}

and avoid catch'm'all approaches.

pakoito avatar Aug 14 '20 11:08 pakoito