Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash from constant data missing ID data #196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jeffdgr8
Copy link

@jeffdgr8 jeffdgr8 commented May 31, 2020

It's possible for StandardAddressVerifier.verifyFields() to crash with:

Fatal Exception: java.lang.NullPointerException: Cannot use null as key
       at com.google.i18n.addressinput.common.Util.checkNotNull(Util.java:123)
       at com.google.i18n.addressinput.common.FieldVerifier.isCountryKey(FieldVerifier.java:439)
       at com.google.i18n.addressinput.common.FieldVerifier.populate(FieldVerifier.java:171)
       at com.google.i18n.addressinput.common.FieldVerifier.<init>(FieldVerifier.java:105)
       at com.google.i18n.addressinput.common.FieldVerifier.refineVerifier(FieldVerifier.java:283)
       at com.google.i18n.addressinput.common.StandardAddressVerifier$Verifier.run(StandardAddressVerifier.java:132)
       at com.google.i18n.addressinput.common.StandardAddressVerifier.verifyFields(StandardAddressVerifier.java:86)

This happens if ClientData.fetchDataIfNotAvailable() fails to fetch data from the server in CacheData.fetchDynamicData(), resulting in getting the data from the RegionDataConstants with CacheData.getFromRegionDataConstants(). The constants data lacks the id key values that are returned from the server, which are required by FieldVerifier.isCountryKey().

This change fixes this by adding the id value for region constant data from its LookupKey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant