Skip to content

ref(android): Deprecate AndroidCurrentDateProvider (JAVA-728) - #6103

Open
runningcode wants to merge 6 commits into
mainfrom
no/java-728-deprecate-android-current-date-provider
Open

ref(android): Deprecate AndroidCurrentDateProvider (JAVA-728)#6103
runningcode wants to merge 6 commits into
mainfrom
no/java-728-deprecate-android-current-date-provider

Conversation

@runningcode

@runningcode runningcode commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Deprecates AndroidCurrentDateProvider.getInstance() in favor of io.sentry.time.MonotonicTicker, and documents the replacement in the type's javadoc.

JAVA-729 tracks the removal.

Why the annotation is on getInstance() and not on the type

We can't add a SuppressWarnings on the imports so I just added it on getInstance since it is the only way in to the class.

Verification

well, it compiles

💡 Motivation and Context

It is super confusing. ICurrentDateProvider has two implementation, one which returns System.currentTimeMillis - a wall clock - and this one which returns SystemClock.uptimeMillis() - a monotonic clock.

💚 How did you test it?

See "Verification" above.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

JAVA-729 migrates the five call sites off the deprecated provider. The Debouncer sites are a behavior change (the debounce interval starts counting deep sleep), and AndroidEnvelopeCache is coupled to TimeSpan's uptime base, so it cannot move alone.

🤖 Generated with Claude Code

AndroidCurrentDateProvider.getCurrentTimeMillis() is
SystemClock.uptimeMillis(): not a date, and not a clock that counts deep
sleep. Neither the name nor the ICurrentDateProvider type says so, and
CurrentDateProvider implements that same interface with epoch
milliseconds, so a call site declaring the interface accepts either and
the two disagree by however long the device has been suspended.
MonotonicTicker names the guarantee it gives and keeps counting through
deep sleep.

The annotation goes on getInstance() rather than on the type. The
Android modules compile at Java 8, where javac still warns on an import
of a deprecated type, and an import declaration cannot carry a
@SuppressWarnings. Deprecating the sole factory method warns every
caller just the same, and each warning lands somewhere a suppression can
go.

Nothing is migrated and nothing is removed. The five suppressed call
sites are the migration list. AndroidEnvelopeCache cannot move on its
own: it subtracts TimeSpan.getStartUptimeMs(), which is
SystemClock.uptimeMillis() too, so moving one operand alone would
subtract two different clock bases.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Sep 11, 2026

Copy link
Copy Markdown

JAVA-728

@sentry

sentry Bot commented Sep 11, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.56.0 (1) release

⚙️ sentry-android Build Distribution Settings

runningcode and others added 4 commits September 11, 2026 17:38
…VA-728)

Deprecating the type rather than getInstance() says the hazard is the
class itself, and warns on every mention of it, the import included.

That is only affordable because this class has five use sites. An import
of a deprecated type still warns at Java 8 (JEP 211 elides those only
from source 9 on), -Werror turns it into an error, and an import
declaration cannot carry a @SuppressWarnings. Dropping the five imports
for fully-qualified names puts every reference inside a declaration that
a suppression can cover. Verified by re-adding one import: the build
fails with "warning: [deprecation] AndroidCurrentDateProvider in
io.sentry.android.core.internal.util has been deprecated".

The suppression comments now point at JAVA-729, which tracks migrating
the call sites, rather than restating the reasoning at each one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deprecating the type required replacing all five imports with fully
qualified names, since an import of a deprecated type warns at Java 8
and an import cannot carry a @SuppressWarnings. That churn bought
nothing. The constructor is private, so getInstance() is the only way
into this class and deprecating it warns every real caller identically.
Type-level deprecation would only add a warning for declaring a variable
of the concrete type, which nothing does: every holder declares
ICurrentDateProvider.

Measured the alternatives before reverting. Neither a class-level
@SuppressWarnings nor a static import silences the import warning; only
a fully qualified name, or a reference from inside the type's own
package, avoids it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode marked this pull request as ready for review September 11, 2026 15:54
@runningcode runningcode added the ship-it PR is ready to merge from a reviewer perspective label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ship-it PR is ready to merge from a reviewer perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate AndroidCurrentDateProvider in favor of MonotonicTicker

1 participant