Skip to content

Commit dcb48d5

Browse files
committed
ref(time): Rename Deadline.in to Deadline.after (JAVA-571)
`in` is a Kotlin hard keyword, so every Kotlin call site had to spell it `Deadline.`in`(...)`. Tests in this repo are Kotlin, and Kotlin callers are expected in the Android and Kotlin integration modules, so the backticks would have spread rather than stayed in one test file. `after` is a plain identifier in both languages and pairs with the existing `hasPassed()` and `isAfter()` vocabulary.
1 parent f9208e5 commit dcb48d5

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎sentry/src/main/java/io/sentry/time/Deadline.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private Deadline(final @NotNull Ticker clock, final long deadlineNanos) {
2424
}
2525

2626
/** A deadline {@code amount} of {@code unit} from now. */
27-
public static @NotNull Deadline in(
27+
public static @NotNull Deadline after(
2828
final @NotNull Ticker clock, final long amount, final @NotNull TimeUnit unit) {
2929
return new Deadline(clock, clock.tickNanos() + unit.toNanos(amount));
3030
}

‎sentry/src/test/java/io/sentry/time/DeadlineTest.kt‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DeadlineTest {
1313
@Test
1414
fun `has not passed before the deadline`() {
1515
val clock = TestTicker()
16-
val deadline = Deadline.`in`(clock, 2, MINUTES)
16+
val deadline = Deadline.after(clock, 2, MINUTES)
1717

1818
clock.advance(119, SECONDS)
1919

@@ -23,7 +23,7 @@ class DeadlineTest {
2323
@Test
2424
fun `has passed once the deadline is reached`() {
2525
val clock = TestTicker()
26-
val deadline = Deadline.`in`(clock, 2, MINUTES)
26+
val deadline = Deadline.after(clock, 2, MINUTES)
2727

2828
clock.advance(2, MINUTES)
2929

@@ -40,7 +40,7 @@ class DeadlineTest {
4040
@Test
4141
fun `remaining counts down and floors at zero`() {
4242
val clock = TestTicker()
43-
val deadline = Deadline.`in`(clock, 1000, MILLISECONDS)
43+
val deadline = Deadline.after(clock, 1000, MILLISECONDS)
4444

4545
assertEquals(1000, deadline.remaining(MILLISECONDS))
4646

@@ -54,7 +54,7 @@ class DeadlineTest {
5454
@Test
5555
fun `remaining rounds up so callers never wake before the deadline`() {
5656
val clock = TestTicker()
57-
val deadline = Deadline.`in`(clock, 1000, MILLISECONDS)
57+
val deadline = Deadline.after(clock, 1000, MILLISECONDS)
5858

5959
// half a millisecond in: 999.5ms left, which must not report as 999
6060
clock.advance(500, java.util.concurrent.TimeUnit.MICROSECONDS)
@@ -65,17 +65,17 @@ class DeadlineTest {
6565
@Test
6666
fun `isAfter compares two deadlines`() {
6767
val clock = TestTicker()
68-
val shorter = Deadline.`in`(clock, 1, SECONDS)
69-
val longer = Deadline.`in`(clock, 5, SECONDS)
68+
val shorter = Deadline.after(clock, 1, SECONDS)
69+
val longer = Deadline.after(clock, 5, SECONDS)
7070

7171
assertTrue(longer.isAfter(shorter))
7272
assertFalse(shorter.isAfter(longer))
7373
}
7474

7575
@Test
7676
fun `isAfter rejects deadlines from different clocks`() {
77-
val deadline = Deadline.`in`(TestTicker(), 1, SECONDS)
78-
val fromAnotherClock = Deadline.`in`(TestTicker(), 5, SECONDS)
77+
val deadline = Deadline.after(TestTicker(), 1, SECONDS)
78+
val fromAnotherClock = Deadline.after(TestTicker(), 5, SECONDS)
7979

8080
assertFailsWith<IllegalArgumentException> { deadline.isAfter(fromAnotherClock) }
8181
}
@@ -84,7 +84,7 @@ class DeadlineTest {
8484
fun `comparisons hold when the tick origin is negative`() {
8585
// System.nanoTime() may start negative; only differences are meaningful.
8686
val clock = TestTicker(Long.MIN_VALUE + 1)
87-
val deadline = Deadline.`in`(clock, 1, SECONDS)
87+
val deadline = Deadline.after(clock, 1, SECONDS)
8888

8989
assertFalse(deadline.hasPassed())
9090
clock.advance(1, SECONDS)

0 commit comments

Comments
 (0)