Skip to content

Commit 5dc86e8

Browse files
authored
chore(android-sqlite): Remove calls to deprecated SentryNanotimeDate constructor (#5562)
1 parent 3a7603a commit 5dc86e8

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

sentry-android-sqlite/src/main/java/io/sentry/sqlite/SQLiteSpanInstrumentation.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import io.sentry.SentryNanotimeDate
1010
import io.sentry.SentryStackTraceFactory
1111
import io.sentry.SpanDataConvention
1212
import io.sentry.SpanStatus
13-
import java.util.Date
1413

1514
private const val SQLITE_TRACE_ORIGIN = "auto.db.sqlite"
1615

1716
/**
1817
* Sentinel for extracting a [SentryNanotimeDate]'s underlying [System.nanoTime] value via
1918
* [SentryDate.diff].
2019
*/
21-
private val EMPTY_NANO_TIME = SentryNanotimeDate(Date(0), 0L)
20+
private val EMPTY_NANO_TIME = SentryNanotimeDate(0, 0L)
2221

2322
/** Span instrumentation for [SentrySQLiteDriver]. */
2423
internal class SQLiteSpanInstrumentation(

sentry-android-sqlite/src/test/java/io/sentry/sqlite/ComputeNanoStartTimestampForChildTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import io.sentry.DateUtils
44
import io.sentry.ISpan
55
import io.sentry.SentryLongDate
66
import io.sentry.SentryNanotimeDate
7-
import java.util.Date
87
import kotlin.test.Test
98
import kotlin.test.assertEquals
109
import kotlin.test.assertNull
@@ -86,7 +85,7 @@ class ComputeNanoStartTimestampForChildTest {
8685
}
8786

8887
private fun spanWithNanotimeStart(wallClockMillis: Long, parentMonotonicNanos: Long): ISpan {
89-
val startDate = SentryNanotimeDate(Date(wallClockMillis), parentMonotonicNanos)
88+
val startDate = SentryNanotimeDate(wallClockMillis, parentMonotonicNanos)
9089
val span = mock<ISpan>()
9190
whenever(span.startDate).thenReturn(startDate)
9291
return span

sentry-android-sqlite/src/test/java/io/sentry/sqlite/SQLiteSpanInstrumentationTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import io.sentry.SpanDataConvention
1111
import io.sentry.SpanStatus
1212
import io.sentry.TransactionContext
1313
import io.sentry.util.thread.IThreadChecker
14-
import java.util.Date
1514
import kotlin.test.Test
1615
import kotlin.test.assertEquals
1716
import kotlin.test.assertFalse
@@ -51,7 +50,7 @@ class SQLiteSpanInstrumentationTest {
5150
// Only the parent date is queued. If startTimestamp() were to call dateProvider.now(),
5251
// the queue would underflow and the test would fail loudly — this is what verifies the
5352
// optimization is in effect.
54-
val parentDate = SentryNanotimeDate(Date(1_000_000L), 100_000_000L)
53+
val parentDate = SentryNanotimeDate(1_000_000L, 100_000_000L)
5554
val sut = setUpWithNanotimeDates(parentDate)
5655

5756
val start = sut.startTimestamp()
@@ -71,7 +70,7 @@ class SQLiteSpanInstrumentationTest {
7170

7271
@Test
7372
fun `startTimestamp falls back to date provider when parent does not use SentryNanotimeDate`() {
74-
val providerDate = SentryNanotimeDate(Date(2_000_000L), 200_000_000L)
73+
val providerDate = SentryNanotimeDate(2_000_000L, 200_000_000L)
7574
val parentSpan = mock<ISpan>()
7675
whenever(parentSpan.startDate).thenReturn(SentryLongDate(1_000_000_000_000_000L))
7776
val options =
@@ -89,7 +88,7 @@ class SQLiteSpanInstrumentationTest {
8988

9089
@Test
9190
fun `startTimestamp falls back to date provider when no transaction is active`() {
92-
val providerDate = SentryNanotimeDate(Date(2_000_000L), 200_000_000L)
91+
val providerDate = SentryNanotimeDate(2_000_000L, 200_000_000L)
9392
val options =
9493
SentryOptions().apply {
9594
dsn = "https://key@sentry.io/proj"

0 commit comments

Comments
 (0)