mirror of https://github.com/grpc/grpc-java.git
core: TimeProvider should not assume that the clock never changes (#4883)
We should reflect changes in the system clock.
This commit is contained in:
parent
6b15aa9e4e
commit
777bbbb121
|
@ -27,12 +27,9 @@ public interface TimeProvider {
|
|||
long currentTimeNanos();
|
||||
|
||||
TimeProvider SYSTEM_TIME_PROVIDER = new TimeProvider() {
|
||||
final long offsetNanos =
|
||||
TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis()) - System.nanoTime();
|
||||
|
||||
@Override
|
||||
public long currentTimeNanos() {
|
||||
return System.nanoTime() + offsetNanos;
|
||||
return TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue