Set clock precision to milliseconds for Datetime->Instant migration#2999
Set clock precision to milliseconds for Datetime->Instant migration#2999CydeWeys wants to merge 1 commit intogoogle:masterfrom
Conversation
Our existing precision is milliseconds so we want to stick with that for Instants. If we want to increase the precision globally after that we can do so all in one go post-migration, but for now, it would be a bad thing to have mixed precision going on just depending on whether a class happens to be migrated yet or not. This PR also migrates all existing DateTime.nowUtc() calls to use the Clock interface, so that when they are migrated they will get the benefit of this precision-setting as well. BUG= http://b/496985355
| AtomicInteger hardDeletedDomains = new AtomicInteger(); | ||
| AtomicReference<ImmutableList<Domain>> domainsBatch = new AtomicReference<>(); | ||
| DateTime startTime = DateTime.now(UTC); | ||
| DateTime startTime = clock.nowUtc(); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
|
|
||
| // Automatically kill the job if it is running for over 20 hours | ||
| } while (DateTime.now(UTC).isBefore(startTime.plusHours(20)) | ||
| } while (clock.nowUtc().isBefore(startTime.plusHours(20)) |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
| updateLastNotificationSentDate( | ||
| registrar, | ||
| DateTime.now(UTC).minusMinutes((int) UPDATE_TIME_OFFSET.getStandardMinutes()), | ||
| clock.nowUtc().minusMinutes((int) UPDATE_TIME_OFFSET.getStandardMinutes()), |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
|
|
||
| public Builder timeToLive(Duration duration) { | ||
| this.table.setExpirationTime(DateTime.now(UTC).plus(duration).getMillis()); | ||
| this.table.setExpirationTime(clock.nowUtc().plus(duration).getMillis()); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
| () -> | ||
| save( | ||
| PremiumListUtils.parseToPremiumList( | ||
| name, currencyUnit, inputData, tm().getTransactionTime()))); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
| consoleApiParams | ||
| .response() | ||
| .setDateHeader("Expires", DateTime.now(UTC).withTimeAtStartOfDay().plusDays(1)); | ||
| .setDateHeader("Expires", clock.nowUtc().withTimeAtStartOfDay().plusDays(1)); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
| keyGen.generateKeyPair(), DEFAULT_ISSUER_FQDN, DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER); | ||
| keyGen.generateKeyPair(), | ||
| DEFAULT_ISSUER_FQDN, | ||
| clock.nowUtc().minusHours(1), |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
| keyGen.generateKeyPair(), | ||
| DEFAULT_ISSUER_FQDN, | ||
| clock.nowUtc().minusHours(1), | ||
| clock.nowUtc().plusDays(1)); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
| public static SelfSignedCaCertificate create(String fqdn) throws Exception { | ||
| return create(fqdn, DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER); | ||
| public static SelfSignedCaCertificate create(String fqdn, Clock clock) throws Exception { | ||
| return create(fqdn, clock.nowUtc().minusHours(1), clock.nowUtc().plusDays(1)); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
| public static SelfSignedCaCertificate create(String fqdn) throws Exception { | ||
| return create(fqdn, DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER); | ||
| public static SelfSignedCaCertificate create(String fqdn, Clock clock) throws Exception { | ||
| return create(fqdn, clock.nowUtc().minusHours(1), clock.nowUtc().plusDays(1)); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
Our existing precision is milliseconds so we want to stick with that for Instants. If we want to increase the precision globally after that we can do so all in one go post-migration, but for now, it would be a bad thing to have mixed precision going on just depending on whether a class happens to be migrated yet or not.
This PR also migrates all existing DateTime.nowUtc() calls to use the Clock interface, so that when they are migrated they will get the benefit of this precision-setting as well.
BUG= http://b/496985355
This change is