Skip to content

fix|reboot detection via boot_id + bump to 4.0.1.alpha#165

Open
PeterWagih90 wants to merge 2 commits into
instacart:masterfrom
PeterWagih90:fix/reboot-boot-id
Open

fix|reboot detection via boot_id + bump to 4.0.1.alpha#165
PeterWagih90 wants to merge 2 commits into
instacart:masterfrom
PeterWagih90:fix/reboot-boot-id

Conversation

@PeterWagih90

Copy link
Copy Markdown

Replace elapsed-time heuristic with /proc/sys/kernel/random/boot_id comparison in TimeKeeper. SntpResult now carries the boot ID captured at sync time; TimeKeeper compares it on cache validation to reliably detect reboots regardless of uptime. Falls back to old elapsed-time check for cached entries that predate this change.

Also add consumer-rules.pro to keep the public TrueTime API under ProGuard/R8, and wire it into the release build type.

Replace elapsed-time heuristic with /proc/sys/kernel/random/boot_id
comparison in TimeKeeper. SntpResult now carries the boot ID captured
at sync time; TimeKeeper compares it on cache validation to reliably
detect reboots regardless of uptime. Falls back to old elapsed-time
check for cached entries that predate this change.

Also add consumer-rules.pro to keep the public TrueTime API under
ProGuard/R8, and wire it into the release build type.
package com.instacart.truetime.sntp

class SntpResult(val ntpResult: LongArray) {
class SntpResult(val ntpResult: LongArray, val bootId: String = "") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Adding bootId to the primary constructor changes the JVM signature of SntpResult from SntpResult(long[]) to SntpResult(long[], String). This type is part of the public surface through CacheProvider and TrueTimeEventListener, so downstream Java callers and already-compiled binaries that instantiate it will break on upgrade. Please keep the old constructor signature available, for example with an explicit secondary constructor delegating to this(ntpResult, "") or another JVM-compatible overload.

Comment thread library/consumer-rules.pro Outdated
@@ -0,0 +1,9 @@
# Keep TrueTime public API
-keep public class com.instacart.truetime.time.TrueTime { *; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TrueTime is declared as an interface, not a class, so this keep rule does not match the library's main public API type. As written, consumer R8/ProGuard can still rename or strip TrueTime. This should be a -keep public interface ... rule.

- consumer-rules.pro: TrueTime is an interface, use -keep public interface
- SntpResult: add explicit secondary constructor(LongArray) to preserve
  JVM binary compatibility for existing Java callers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant