Skip to content

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

Description

@gpunto

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions