Use DateTimeUtils.currentTimeMillis() to get current time
This method from joda-time supports replacing the system time provider with a custom provider for tests. Since it is verbose, and we expect more related methods, put it in the more succinct TimeUtil.nowMs(). This commit covers the trivial cases in the server side; client-side code still uses System.currentTimeMillis(). Change-Id: I6c56e8c5bbb0cf7b0271e431d1ebdb532967b9e8
This commit is contained in:
@@ -17,6 +17,7 @@ package com.google.gerrit.pgm.http.jetty;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
|
||||
import org.apache.log4j.Appender;
|
||||
import org.apache.log4j.AsyncAppender;
|
||||
@@ -95,7 +96,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
|
||||
final LoggingEvent event = new LoggingEvent( //
|
||||
Logger.class.getName(), // fqnOfCategoryClass
|
||||
log, // logger
|
||||
System.currentTimeMillis(), // when
|
||||
TimeUtil.nowMs(), // when
|
||||
Level.INFO, // level
|
||||
"", // message text
|
||||
"HTTPD", // thread name
|
||||
@@ -162,7 +163,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
|
||||
dateFormat = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z");
|
||||
dateFormat.setTimeZone(tz);
|
||||
|
||||
lastTimeMillis = System.currentTimeMillis();
|
||||
lastTimeMillis = TimeUtil.nowMs();
|
||||
lastTimeString = dateFormat.format(new Date(lastTimeMillis));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.AuthType;
|
||||
import com.google.gerrit.server.config.ConfigUtil;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -596,7 +597,7 @@ public class JettyServer {
|
||||
if (properties.contains("PATH")) {
|
||||
proc.environment().put("PATH", properties.getProperty("PATH"));
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
long start = TimeUtil.nowMs();
|
||||
Process rebuild = proc.start();
|
||||
byte[] out;
|
||||
InputStream in = rebuild.getInputStream();
|
||||
@@ -619,7 +620,7 @@ public class JettyServer {
|
||||
System.exit(status);
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis() - start;
|
||||
long time = TimeUtil.nowMs() - start;
|
||||
log.info(String.format("UPDATED %s in %.3fs", target, time / 1000.0));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user