[x] I have validated my changes against all supported platform versions
Related issues
N/A
Describe the solution you've provided
When diagnosticOptOut is true and the events buffer is full, a null pointer exception will be thrown when trying to send an event. Example stacktrace:
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.launchdarkly.sdk.android.DiagnosticStore.incrementDroppedEventCount()' on a null object reference
at com.launchdarkly.sdk.android.LDClient.sendEvent(LDClient.java:668)
at com.launchdarkly.sdk.android.LDClient.identifyInternal(LDClient.java:314)
at com.launchdarkly.sdk.android.LDClient.identifyInstances(LDClient.java:335)
at com.launchdarkly.sdk.android.LDClient.identify(LDClient.java:301)
at com.launchdarkly.sdk.android.LDClientTest.testEventBufferFillsUp(LDClientTest.java:661)
This occurs because diagnosticStore is set to null when diagnosticOptOut is true (see here) and sendEvent() assumes diagnosticStore will not be null (see here)
Other usages of diagnosticStore are gated with if (diagnosticStore != null) to avoid throwing an exception (see here and here)
This pull request adds a similar gate to avoid the null pointer exception.
Requirements
Related issues
N/A
Describe the solution you've provided
When
diagnosticOptOut
istrue
and the events buffer is full, a null pointer exception will be thrown when trying to send an event. Example stacktrace:This occurs because
diagnosticStore
is set tonull
whendiagnosticOptOut
istrue
(see here) andsendEvent()
assumesdiagnosticStore
will not benull
(see here)Other usages of
diagnosticStore
are gated withif (diagnosticStore != null)
to avoid throwing an exception (see here and here)This pull request adds a similar gate to avoid the null pointer exception.
Describe alternatives you've considered
N/A
Additional context
N/A