Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object Datadog {
InternalLogger.Target.USER,
{ MESSAGE_ALREADY_INITIALIZED }
)
return existing
return NoOpInternalSdkCore

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Return existing core on duplicate initialization

Returning NoOpInternalSdkCore here breaks initialize() idempotency for callers that keep and reuse the returned SdkCore (for example, val core = Datadog.initialize(...); Rum.enable(..., core)). In a common defensive pattern where a library calls initialize() after the app already did, the second call now hands back a no-op core, so subsequent feature registration and user/context updates are silently dropped even though a real instance is already active.

Useful? React with 👍 / 👎.

}

val sdkInstanceId = hashGenerator.generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ internal class DatadogTest {
}

@Test
fun `M warn W initialize() + initialize()`() {
fun `M warn and return no-op W initialize() + initialize()`() {
// When
val initialized1 = Datadog.initialize(
Datadog.initialize(
appContext.mockInstance,
fakeConfiguration,
fakeConsent
Expand All @@ -147,7 +147,7 @@ internal class DatadogTest {
InternalLogger.Target.USER,
Datadog.MESSAGE_ALREADY_INITIALIZED
)
assertThat(initialized2).isSameAs(initialized1)
assertThat(initialized2).isSameAs(NoOpInternalSdkCore)
}

@Test
Expand Down
Loading