Fix LogFileCompressor scheduling
Since: I1e665848cd7cd5f93628db97c0af17900d243f9d initial delay for the
scheduled task was not being calculated correctly, leading to the task
initially being run much later than expected.
Change-Id: I88dc9b10785b15f46eb21463a48e49d4416cd651
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java
index 666d03c..919136e 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java
@@ -29,8 +29,9 @@
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
import java.util.concurrent.Future;
import java.util.zip.GZIPOutputStream;
import org.slf4j.Logger;
@@ -62,8 +63,9 @@
//compress log once and then schedule compression every day at 11:00pm
queue.getDefaultQueue().execute(compressor);
ZoneId zone = ZoneId.systemDefault();
- LocalDate now = LocalDate.now(zone);
- long milliSecondsUntil11pm = now.atStartOfDay(zone).plusHours(23).toInstant().toEpochMilli();
+ LocalDateTime now = LocalDateTime.now(zone);
+ long milliSecondsUntil11pm =
+ now.until(now.withHour(23).withMinute(0).withSecond(0).withNano(0), ChronoUnit.MILLIS);
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
queue