Skip to content

RUM-2780: Return no-op core when instance is already initialized#3271

Open
ambushwork wants to merge 1 commit intodevelopfrom
yl/RUM-2780/return-noop-core-when-initialized
Open

RUM-2780: Return no-op core when instance is already initialized#3271
ambushwork wants to merge 1 commit intodevelopfrom
yl/RUM-2780/return-noop-core-when-initialized

Conversation

@ambushwork
Copy link
Member

What does this PR do?

we should return a no-op instance and prevent leaks between orgs.

Motivation

RUM-2780

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@datadog-prod-us1-6

This comment has been minimized.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.42%. Comparing base (d9dbeca) to head (1efebab).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3271      +/-   ##
===========================================
+ Coverage    71.38%   71.42%   +0.04%     
===========================================
  Files          942      942              
  Lines        34823    34822       -1     
  Branches      5901     5901              
===========================================
+ Hits         24857    24871      +14     
+ Misses        8297     8283      -14     
+ Partials      1669     1668       -1     
Files with missing lines Coverage Δ
...ore/src/main/kotlin/com/datadog/android/Datadog.kt 71.43% <100.00%> (-0.31%) ⬇️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ambushwork ambushwork marked this pull request as ready for review March 18, 2026 16:10
@ambushwork ambushwork requested review from a team as code owners March 18, 2026 16:10
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1efebaba2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

{ 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 👍 / 👎.

Copy link
Contributor

@hamorillo hamorillo left a comment

Choose a reason for hiding this comment

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

🚀 LGTM! As you mentioned in the ticket, we need to block merging this PR until v4, though.

* @param context your application context
* @param configuration the configuration for the SDK library
* @param trackingConsent as the initial state of the tracking consent flag
* @return the initialized SDK instance, or null if something prevents the SDK from
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Should we add that we can now return NoOpInternalSdkCore?

@ambushwork ambushwork added the v4 The PR should wait for the release of Android SDK v4 label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 The PR should wait for the release of Android SDK v4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants