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

NPE when sharing a card #342

Closed
brarcher opened this issue Jan 9, 2020 · 2 comments · Fixed by #343
Closed

NPE when sharing a card #342

brarcher opened this issue Jan 9, 2020 · 2 comments · Fixed by #343

Comments

@brarcher
Copy link
Owner

brarcher commented Jan 9, 2020

The following exception is reported multiple times from Beta users from Play on release v0.26:

java.lang.NullPointerException: 
  at protect.card_locker.ImportURIHelper.toUri (ImportURIHelper.java:60)
  at protect.card_locker.ImportURIHelper.startShareIntent (ImportURIHelper.java:77)
  at protect.card_locker.MainActivity.onContextItemSelected (MainActivity.java:210)

This is the following line:

uriBuilder.appendQueryParameter(HEADER_COLOR, loyaltyCard.headerColor.toString());

Android Studio does surface a warning that headerColor may be null, but that may be a general warning, as nothing in the contract to toUri prevents a card field from being null. The question is, under what conditions is the header color null?

@brarcher
Copy link
Owner Author

brarcher commented Jan 9, 2020

@TheLastProject, are you interested in taking a look at this issue with sharing loyalty cards? If not, I can take a look when I have time.

Right now v0.26 is in Beta. I'd like to address this issue before taking the new features out of Beta.

@TheLastProject
Copy link
Contributor

It is allowed to be null in the database so my guess would be that these are old loyalty cards saved before the header and title colour fields were introduced. The rest of the code has null checks for the header fields to deal with this.

I will soon (probably this evening) patch this as follows:

  • It will not add headerColor and headerTextColor to the uri if they are null
  • Add tests to ensure that this situation doesn't crash sharing and that those missing parameters don't cause importing to fail

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 a pull request may close this issue.

2 participants