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

FilteredMParticleUser.getConsentState() returns null even though the interface function has @NonNull #473

Open
gpunto opened this issue Feb 14, 2024 · 0 comments

Comments

@gpunto
Copy link

gpunto commented Feb 14, 2024

Hello!

I'm using ConsentState.withConsentState(user.consentState) to create a builder to update consent in onUserIdentified. However, when user is FilteredMParticleUser this will crash because consentState returns null. Partial stacktrace:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Map com.mparticle.consent.ConsentState.getGDPRConsentState()' on a null object reference
	at com.mparticle.consent.ConsentState$Builder.<init>(SourceFile:15)
	at com.mparticle.consent.ConsentState$Builder.<init>(SourceFile:1)
	at com.mparticle.consent.ConsentState.withConsentState(SourceFile:1)

This should likely be caught at compile-time, since ConsentState.withConsentState requires a non-null ConsentState. However, the problem is that MParticleUser.getConsentState() is annotated as NonNull, so the Kotlin compiler trusts the annotation, while the FilteredMParticleUser implementation returns null.

For reference, I was taking this kit as an example implementation.

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

No branches or pull requests

1 participant