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:
parent
925bcc15e0
commit
46b1ac8f07
@ -11,6 +11,7 @@ import com.google.common.hash.BloomFilter;
|
||||
import com.google.common.hash.Funnel;
|
||||
import com.google.common.hash.Funnels;
|
||||
import com.google.common.hash.PrimitiveSink;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import org.h2.jdbc.JdbcSQLException;
|
||||
@ -114,7 +115,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
@Override
|
||||
public void put(final K key, V val) {
|
||||
final ValueHolder<V> h = new ValueHolder<V>(val);
|
||||
h.created = System.currentTimeMillis();
|
||||
h.created = TimeUtil.nowMs();
|
||||
mem.put(key, h);
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
@ -182,7 +183,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
|
||||
long delay = cal.getTimeInMillis() - System.currentTimeMillis();
|
||||
long delay = cal.getTimeInMillis() - TimeUtil.nowMs();
|
||||
service.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -245,7 +246,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
}
|
||||
|
||||
final ValueHolder<V> h = new ValueHolder<V>(loader.load(key));
|
||||
h.created = System.currentTimeMillis();
|
||||
h.created = TimeUtil.nowMs();
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -461,7 +462,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
c.touch =c.conn.prepareStatement("UPDATE data SET accessed=? WHERE k=?");
|
||||
}
|
||||
try {
|
||||
c.touch.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
|
||||
c.touch.setTimestamp(1, new Timestamp(TimeUtil.nowMs()));
|
||||
keyType.set(c.touch, 2, key);
|
||||
c.touch.executeUpdate();
|
||||
} finally {
|
||||
@ -490,7 +491,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
||||
keyType.set(c.put, 1, key);
|
||||
c.put.setObject(2, holder.value);
|
||||
c.put.setTimestamp(3, new Timestamp(holder.created));
|
||||
c.put.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
|
||||
c.put.setTimestamp(4, new Timestamp(TimeUtil.nowMs()));
|
||||
c.put.executeUpdate();
|
||||
holder.clean = true;
|
||||
} finally {
|
||||
|
@ -14,14 +14,15 @@
|
||||
|
||||
package com.google.gerrit.httpd;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.audit.AuditEvent;
|
||||
import com.google.gerrit.audit.AuditService;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AccountManager;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@ -80,7 +81,7 @@ class HttpLogoutServlet extends HttpServlet {
|
||||
final String sid = webSession.get().getSessionId();
|
||||
final CurrentUser currentUser = webSession.get().getCurrentUser();
|
||||
final String what = "sign out";
|
||||
final long when = System.currentTimeMillis();
|
||||
final long when = TimeUtil.nowMs();
|
||||
|
||||
try {
|
||||
doLogout(req, rsp);
|
||||
|
@ -22,6 +22,7 @@ import static com.google.gerrit.server.ioutil.BasicSerialization.writeBytes;
|
||||
import static com.google.gerrit.server.ioutil.BasicSerialization.writeFixInt64;
|
||||
import static com.google.gerrit.server.ioutil.BasicSerialization.writeString;
|
||||
import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32;
|
||||
import static com.google.gerrit.server.util.TimeUtil.nowMs;
|
||||
import static java.util.concurrent.TimeUnit.HOURS;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
@ -53,10 +54,6 @@ class WebSessionManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(WebSessionManager.class);
|
||||
static final String CACHE_NAME = "web_sessions";
|
||||
|
||||
static long now() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private final long sessionMaxAgeMillis;
|
||||
private final SecureRandom prng;
|
||||
private final Cache<String, Val> self;
|
||||
@ -117,7 +114,7 @@ class WebSessionManager {
|
||||
final long halfAgeRefresh = sessionMaxAgeMillis >>> 1;
|
||||
final long minRefresh = MILLISECONDS.convert(1, HOURS);
|
||||
final long refresh = Math.min(halfAgeRefresh, minRefresh);
|
||||
final long now = now();
|
||||
final long now = nowMs();
|
||||
final long refreshCookieAt = now + refresh;
|
||||
final long expiresAt = now + sessionMaxAgeMillis;
|
||||
if (sid == null) {
|
||||
@ -150,7 +147,7 @@ class WebSessionManager {
|
||||
|
||||
Val get(final Key key) {
|
||||
Val val = self.getIfPresent(key.token);
|
||||
if (val != null && val.expiresAt <= now()) {
|
||||
if (val != null && val.expiresAt <= nowMs()) {
|
||||
self.invalidate(key.token);
|
||||
return null;
|
||||
}
|
||||
@ -223,7 +220,7 @@ class WebSessionManager {
|
||||
}
|
||||
|
||||
boolean needsCookieRefresh() {
|
||||
return refreshCookieAt <= now();
|
||||
return refreshCookieAt <= nowMs();
|
||||
}
|
||||
|
||||
boolean isPersistentCookie() {
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.server.FileTypeRegistry;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtexpui.server.CacheHeaders;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
@ -333,7 +334,7 @@ public class CatServlet extends HttpServlet {
|
||||
md.update(req.getRemoteAddr().getBytes("UTF-8"));
|
||||
md.update(buf, 0, 4);
|
||||
|
||||
NB.encodeInt64(buf, 0, System.currentTimeMillis());
|
||||
NB.encodeInt64(buf, 0, TimeUtil.nowMs());
|
||||
md.update(buf, 0, 8);
|
||||
|
||||
rng.nextBytes(buf);
|
||||
|
@ -16,7 +16,9 @@ package com.google.gerrit.httpd.restapi;
|
||||
|
||||
import static com.google.common.base.Charsets.UTF_8;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import static java.math.RoundingMode.CEILING;
|
||||
|
||||
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_CONFLICT;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_CREATED;
|
||||
@ -76,6 +78,7 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.OptionUtil;
|
||||
import com.google.gerrit.server.OutputFormat;
|
||||
import com.google.gerrit.server.account.CapabilityUtils;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.FieldNamingPolicy;
|
||||
@ -185,7 +188,7 @@ public class RestApiServlet extends HttpServlet {
|
||||
@Override
|
||||
protected final void service(HttpServletRequest req, HttpServletResponse res)
|
||||
throws ServletException, IOException {
|
||||
long auditStartTs = System.currentTimeMillis();
|
||||
long auditStartTs = TimeUtil.nowMs();
|
||||
res.setHeader("Content-Disposition", "attachment");
|
||||
res.setHeader("X-Content-Type-Options", "nosniff");
|
||||
int status = SC_OK;
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.common.errors.NotSignedInException;
|
||||
import com.google.gerrit.httpd.WebSession;
|
||||
import com.google.gerrit.server.AccessPath;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gwtjsonrpc.common.RemoteJsonService;
|
||||
import com.google.gwtjsonrpc.server.ActiveCall;
|
||||
@ -238,7 +239,7 @@ final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall>
|
||||
final HttpServletResponse o) {
|
||||
super(i, o);
|
||||
this.session = session;
|
||||
this.when = System.currentTimeMillis();
|
||||
this.when = TimeUtil.nowMs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -290,7 +291,7 @@ final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall>
|
||||
}
|
||||
|
||||
public long getElapsed() {
|
||||
return System.currentTimeMillis() - when;
|
||||
return TimeUtil.nowMs() - when;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
java_library(
|
||||
name = 'launcher',
|
||||
srcs = glob(['src/main/java/**/*.java']),
|
||||
deps = ['//lib/joda:joda-time'],
|
||||
visibility = [
|
||||
'//gerrit-acceptance-tests/...',
|
||||
'//gerrit-main:main_lib',
|
||||
|
@ -17,6 +17,8 @@ package com.google.gerrit.launcher;
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
import org.joda.time.DateTimeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@ -506,7 +508,7 @@ public final class GerritLauncher {
|
||||
//
|
||||
final File[] tmpEntries = tmp.listFiles();
|
||||
if (tmpEntries != null) {
|
||||
final long now = System.currentTimeMillis();
|
||||
final long now = DateTimeUtils.currentTimeMillis();
|
||||
final long expired = now - MILLISECONDS.convert(7, DAYS);
|
||||
for (final File tmpEntry : tmpEntries) {
|
||||
if (tmpEntry.isDirectory() && tmpEntry.lastModified() < expired) {
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ java_library2(
|
||||
'//lib/guice:guice-assistedinject',
|
||||
'//lib/guice:guice-servlet',
|
||||
'//lib/jgit:jgit',
|
||||
'//lib/joda:joda-time',
|
||||
'//lib/log:api',
|
||||
'//lib/prolog:prolog-cafe',
|
||||
],
|
||||
|
@ -19,6 +19,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
|
||||
public class AuditEvent {
|
||||
|
||||
@ -94,7 +95,7 @@ public class AuditEvent {
|
||||
this.params = Objects.firstNonNull(params, EMPTY_PARAMS);
|
||||
this.uuid = new UUID();
|
||||
this.result = result;
|
||||
this.elapsed = System.currentTimeMillis() - timeAtStart;
|
||||
this.elapsed = TimeUtil.nowMs() - timeAtStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ import com.google.gerrit.common.Version;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@ -222,7 +223,7 @@ public class PrologCompiler implements Callable<PrologCompiler.Status> {
|
||||
/** Takes compiled prolog .class files, puts them into the jar file. */
|
||||
private void createJar(File archiveFile, List<String> toBeJared,
|
||||
File tempDir, ObjectId metaConfig, ObjectId rulesId) throws IOException {
|
||||
long now = System.currentTimeMillis();
|
||||
long now = TimeUtil.nowMs();
|
||||
File tmpjar = File.createTempFile(".rulec_", ".jar", archiveFile.getParentFile());
|
||||
try {
|
||||
Manifest mf = new Manifest();
|
||||
@ -315,4 +316,4 @@ public class PrologCompiler implements Callable<PrologCompiler.Status> {
|
||||
}
|
||||
dir.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.RefControl;
|
||||
import com.google.gerrit.server.util.IdGenerator;
|
||||
import com.google.gerrit.server.util.MagicBranch;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmConcurrencyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
||||
@ -144,7 +145,7 @@ public class ChangeUtil {
|
||||
}
|
||||
|
||||
public static void updated(final Change c) {
|
||||
c.resetLastUpdatedOn();
|
||||
c.setLastUpdatedOn(new Timestamp(TimeUtil.nowMs()));
|
||||
computeSortKey(c);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.gerrit.common.ChangeHooks;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@ -46,6 +45,7 @@ import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.project.RefControl;
|
||||
import com.google.gerrit.server.ssh.NoSshInfo;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.AtomicUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
@ -332,7 +332,7 @@ public class PatchSetInserter {
|
||||
if (patchSet == null) {
|
||||
patchSet = new PatchSet(
|
||||
ChangeUtil.nextPatchSetId(git, change.currentPatchSetId()));
|
||||
patchSet.setCreatedOn(new Timestamp(System.currentTimeMillis()));
|
||||
patchSet.setCreatedOn(new Timestamp(TimeUtil.nowMs()));
|
||||
patchSet.setUploader(change.getOwner());
|
||||
patchSet.setRevision(new RevId(commit.name()));
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MergeQueue;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.AtomicUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
@ -178,7 +179,7 @@ public class Submit implements RestModifyView<RevisionResource, Input>,
|
||||
|
||||
public Change submit(RevisionResource rsrc, IdentifiedUser caller)
|
||||
throws OrmException, IOException {
|
||||
final Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
final Timestamp timestamp = new Timestamp(TimeUtil.nowMs());
|
||||
Change change = rsrc.getChange();
|
||||
ReviewDb db = dbProvider.get();
|
||||
db.changes().beginTransaction(change.getId());
|
||||
|
@ -20,6 +20,7 @@ import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gerrit.reviewdb.client.ContactInformation;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.UrlEncoded;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
import com.google.inject.ProvisionException;
|
||||
@ -213,7 +214,7 @@ class EncryptedContactStore implements ContactStore {
|
||||
throws ContactInformationStoreException {
|
||||
Timestamp on = account.getContactFiledOn();
|
||||
if (on == null) {
|
||||
on = new Timestamp(System.currentTimeMillis());
|
||||
on = new Timestamp(TimeUtil.nowMs());
|
||||
}
|
||||
|
||||
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
@ -27,6 +27,7 @@ import com.google.gerrit.server.config.RequestScopedReviewDbProvider;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gerrit.server.util.RequestContext;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
@ -155,7 +156,7 @@ public class ChangeMergeQueue implements MergeQueue {
|
||||
@Override
|
||||
public synchronized void recheckAfter(final Branch.NameKey branch,
|
||||
final long delay, final TimeUnit delayUnit) {
|
||||
final long now = System.currentTimeMillis();
|
||||
final long now = TimeUtil.nowMs();
|
||||
final long at = now + MILLISECONDS.convert(delay, delayUnit);
|
||||
RecheckJob e = recheck.get(branch);
|
||||
if (e == null) {
|
||||
@ -216,7 +217,7 @@ public class ChangeMergeQueue implements MergeQueue {
|
||||
}
|
||||
|
||||
private synchronized void recheck(final RecheckJob e) {
|
||||
final long remainingDelay = e.recheckAt - System.currentTimeMillis();
|
||||
final long remainingDelay = e.recheckAt - TimeUtil.nowMs();
|
||||
if (MILLISECONDS.convert(10, SECONDS) < remainingDelay) {
|
||||
// Woke up too early, the job deadline was pushed back.
|
||||
// Reschedule for the new deadline. We allow for a small
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@ -159,7 +160,7 @@ public class CherryPick extends SubmitStrategy {
|
||||
PatchSet.Id id =
|
||||
ChangeUtil.nextPatchSetId(args.repo, n.change.currentPatchSetId());
|
||||
final PatchSet ps = new PatchSet(id);
|
||||
ps.setCreatedOn(new Timestamp(System.currentTimeMillis()));
|
||||
ps.setCreatedOn(new Timestamp(TimeUtil.nowMs()));
|
||||
ps.setUploader(submitAudit.getAccountId());
|
||||
ps.setRevision(new RevId(newCommit.getId().getName()));
|
||||
insertAncestors(args.db, ps.getId(), newCommit);
|
||||
|
@ -15,10 +15,12 @@
|
||||
package com.google.gerrit.server.git;
|
||||
|
||||
import static com.google.gerrit.server.git.MergeUtil.getSubmitter;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.HOURS;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
import static org.eclipse.jgit.lib.RefDatabase.ALL;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
@ -59,6 +61,7 @@ import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.AtomicUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
@ -705,7 +708,7 @@ public class MergeOp {
|
||||
final Capable capable;
|
||||
final Change c = commit.change;
|
||||
final boolean submitStillPossible = isSubmitForMissingCommitsStillPossible(commit);
|
||||
final long now = System.currentTimeMillis();
|
||||
final long now = TimeUtil.nowMs();
|
||||
final long waitUntil = c.getLastUpdatedOn().getTime() + DEPENDENCY_DELAY;
|
||||
if (submitStillPossible && now < waitUntil) {
|
||||
// If we waited a short while we might still be able to get
|
||||
@ -956,7 +959,7 @@ public class MergeOp {
|
||||
@Nullable PatchSetApproval submitter,
|
||||
ChangeMessage msg) {
|
||||
if (submitter != null
|
||||
&& System.currentTimeMillis() - submitter.getGranted().getTime()
|
||||
&& TimeUtil.nowMs() - submitter.getGranted().getTime()
|
||||
> MAX_SUBMIT_WINDOW) {
|
||||
return RetryStatus.UNSUBMIT;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ package com.google.gerrit.server.git;
|
||||
import static com.google.gerrit.server.git.MultiProgressMonitor.UNKNOWN;
|
||||
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromApprovals;
|
||||
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
||||
import static org.eclipse.jgit.lib.RefDatabase.ALL;
|
||||
import static org.eclipse.jgit.transport.ReceiveCommand.Result.NOT_ATTEMPTED;
|
||||
@ -94,6 +95,7 @@ import com.google.gerrit.server.project.RefControl;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gerrit.server.util.MagicBranch;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.util.cli.CmdLineParser;
|
||||
import com.google.gwtorm.server.AtomicUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@ -124,9 +126,9 @@ import org.eclipse.jgit.transport.AdvertiseRefsHook;
|
||||
import org.eclipse.jgit.transport.AdvertiseRefsHookChain;
|
||||
import org.eclipse.jgit.transport.BaseReceivePack;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand.Result;
|
||||
import org.eclipse.jgit.transport.ReceivePack;
|
||||
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
|
||||
import org.eclipse.jgit.transport.UploadPack;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.Option;
|
||||
@ -1740,7 +1742,7 @@ public class ReceiveCommits {
|
||||
PatchSet.Id id =
|
||||
ChangeUtil.nextPatchSetId(allRefs, change.currentPatchSetId());
|
||||
newPatchSet = new PatchSet(id);
|
||||
newPatchSet.setCreatedOn(new Timestamp(System.currentTimeMillis()));
|
||||
newPatchSet.setCreatedOn(new Timestamp(TimeUtil.nowMs()));
|
||||
newPatchSet.setUploader(currentUser.getAccountId());
|
||||
newPatchSet.setRevision(toRevId(newCommit));
|
||||
if (magicBranch != null && magicBranch.isDraft()) {
|
||||
|
@ -18,6 +18,7 @@ import com.google.gerrit.common.Version;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.server.config.ConfigUtil;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
@ -151,7 +152,7 @@ public class SmtpEmailSender implements EmailSender {
|
||||
setMissingHeader(hdrs, "Importance", importance);
|
||||
}
|
||||
if(expiryDays > 0) {
|
||||
Date expiry = new Date(System.currentTimeMillis() +
|
||||
Date expiry = new Date(TimeUtil.nowMs() +
|
||||
expiryDays * 24 * 60 * 60 * 1000L );
|
||||
setMissingHeader(hdrs, "Expiry-Date",
|
||||
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z").format(expiry));
|
||||
|
@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.plugins;
|
||||
|
||||
import com.google.gerrit.server.git.WorkQueue;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@ -52,7 +53,7 @@ class PluginCleanerTask implements Runnable {
|
||||
self = null;
|
||||
|
||||
if (0 < left) {
|
||||
long waiting = System.currentTimeMillis() - start;
|
||||
long waiting = TimeUtil.nowMs() - start;
|
||||
PluginLoader.log.warn(String.format(
|
||||
"%d plugins still waiting to be reclaimed after %d minutes",
|
||||
pending,
|
||||
@ -76,7 +77,7 @@ class PluginCleanerTask implements Runnable {
|
||||
|
||||
synchronized void clean(int expect) {
|
||||
if (self == null && pending == 0) {
|
||||
start = System.currentTimeMillis();
|
||||
start = TimeUtil.nowMs();
|
||||
}
|
||||
pending = expect;
|
||||
ensureScheduled();
|
||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.config.ConfigUtil;
|
||||
import com.google.gerrit.server.index.ChangeField;
|
||||
import com.google.gerrit.server.index.TimestampRangePredicate;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
@ -37,7 +38,7 @@ public class AgePredicate extends TimestampRangePredicate<ChangeData> {
|
||||
|
||||
long s = ConfigUtil.getTimeUnit(getValue(), 0, SECONDS);
|
||||
long ms = MILLISECONDS.convert(s, SECONDS);
|
||||
this.cut = System.currentTimeMillis() - ms;
|
||||
this.cut = TimeUtil.nowMs() - ms;
|
||||
}
|
||||
|
||||
public Timestamp getMinTimestamp() {
|
||||
|
@ -31,6 +31,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.query.Predicate;
|
||||
import com.google.gerrit.server.query.QueryParseException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
@ -292,7 +293,7 @@ public class QueryProcessor {
|
||||
|
||||
try {
|
||||
final QueryStatsAttribute stats = new QueryStatsAttribute();
|
||||
stats.runTimeMilliseconds = System.currentTimeMillis();
|
||||
stats.runTimeMilliseconds = TimeUtil.nowMs();
|
||||
|
||||
List<ChangeData> results = queryChanges(queryString);
|
||||
ChangeAttribute c = null;
|
||||
@ -362,7 +363,7 @@ public class QueryProcessor {
|
||||
stats.resumeSortKey = c.sortKey;
|
||||
}
|
||||
stats.runTimeMilliseconds =
|
||||
System.currentTimeMillis() - stats.runTimeMilliseconds;
|
||||
TimeUtil.nowMs() - stats.runTimeMilliseconds;
|
||||
show(stats);
|
||||
} catch (OrmException err) {
|
||||
log.error("Cannot execute query: " + queryString, err);
|
||||
|
@ -39,6 +39,7 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.git.VersionedMetaData.BatchMetaDataUpdate;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.jdbc.JdbcSchema;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
@ -348,7 +349,7 @@ public class Schema_65 extends SchemaVersion {
|
||||
" reviewed_on, review_comments " +
|
||||
"FROM account_agreements WHERE status = 'V'");
|
||||
try {
|
||||
long minTime = System.currentTimeMillis();
|
||||
long minTime = TimeUtil.nowMs();
|
||||
while (rs.next()) {
|
||||
Account.Id accountId = new Account.Id(rs.getInt(1));
|
||||
Account.Id reviewerId = new Account.Id(rs.getInt(4));
|
||||
|
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.util;
|
||||
|
||||
import org.joda.time.DateTimeUtils;
|
||||
|
||||
/** Static utility methods for dealing with dates and times. */
|
||||
public class TimeUtil {
|
||||
public static long nowMs() {
|
||||
return DateTimeUtils.currentTimeMillis();
|
||||
}
|
||||
|
||||
private TimeUtil() {
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.rules;
|
||||
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Module;
|
||||
|
||||
@ -116,7 +117,7 @@ public abstract class PrologTestCase extends TestCase {
|
||||
|
||||
public void runPrologBasedTests() {
|
||||
int errors = 0;
|
||||
long start = System.currentTimeMillis();
|
||||
long start = TimeUtil.nowMs();
|
||||
|
||||
for (Term test : tests) {
|
||||
PrologEnvironment env = envFactory.create(machine);
|
||||
@ -159,7 +160,7 @@ public abstract class PrologTestCase extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
long end = TimeUtil.nowMs();
|
||||
System.out.println("-------------------------------");
|
||||
System.out.format("Prolog tests: %d, Failures: %d, Time elapsed %.3f sec",
|
||||
tests.size(), errors, (end - start) / 1000.0);
|
||||
|
@ -30,14 +30,15 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.CommentRange;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment.Status;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.CommentRange;
|
||||
import com.google.gerrit.reviewdb.server.PatchLineCommentAccess;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.account.AccountInfo;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.ListResultSet;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
import com.google.inject.AbstractModule;
|
||||
@ -109,7 +110,7 @@ public class CommentsTest extends TestCase {
|
||||
PatchSet ps2 = new PatchSet(psId2);
|
||||
expect(revRes2.getPatchSet()).andReturn(ps2);
|
||||
|
||||
long timeBase = System.currentTimeMillis();
|
||||
long timeBase = TimeUtil.nowMs();
|
||||
plc1 = newPatchLineComment(psId1, "Comment1", null,
|
||||
"FileOne.txt", Side.REVISION, 1, account1, timeBase,
|
||||
"First Comment", new CommentRange(1, 2, 3, 4));
|
||||
|
@ -27,6 +27,7 @@ import com.google.gerrit.server.git.WorkQueue;
|
||||
import com.google.gerrit.server.git.WorkQueue.CancelableRunnable;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.sshd.SshScope.Context;
|
||||
import com.google.gerrit.util.cli.CmdLineParser;
|
||||
import com.google.gerrit.util.cli.EndOfOptionsHandler;
|
||||
@ -429,7 +430,7 @@ public abstract class BaseCommand implements Command {
|
||||
int rc = 0;
|
||||
final Context old = sshScope.set(context);
|
||||
try {
|
||||
context.started = System.currentTimeMillis();
|
||||
context.started = TimeUtil.nowMs();
|
||||
thisThread.setName("SSH " + taskName);
|
||||
|
||||
if (thunk instanceof ProjectCommandRunnable) {
|
||||
|
@ -25,6 +25,7 @@ import com.google.gerrit.server.PeerDaemonUser;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.util.IdGenerator;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.sshd.SshScope.Context;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@ -109,7 +110,7 @@ class SshLog implements LifecycleListener {
|
||||
final LoggingEvent event = new LoggingEvent( //
|
||||
Logger.class.getName(), // fqnOfCategoryClass
|
||||
log, // logger
|
||||
System.currentTimeMillis(), // when
|
||||
TimeUtil.nowMs(), // when
|
||||
Level.INFO, // level
|
||||
"AUTH FAILURE FROM " + sd.getRemoteAddressAsString(), // message text
|
||||
"SSHD", // thread name
|
||||
@ -133,7 +134,7 @@ class SshLog implements LifecycleListener {
|
||||
|
||||
void onExecute(DispatchCommand dcmd, int exitValue) {
|
||||
final Context ctx = context.get();
|
||||
ctx.finished = System.currentTimeMillis();
|
||||
ctx.finished = TimeUtil.nowMs();
|
||||
|
||||
String cmd = extractWhat(dcmd);
|
||||
|
||||
@ -219,7 +220,7 @@ class SshLog implements LifecycleListener {
|
||||
final LoggingEvent event = new LoggingEvent( //
|
||||
Logger.class.getName(), // fqnOfCategoryClass
|
||||
log, // logger
|
||||
System.currentTimeMillis(), // when
|
||||
TimeUtil.nowMs(), // when
|
||||
Level.INFO, // level
|
||||
msg, // message text
|
||||
"SSHD", // thread name
|
||||
@ -473,7 +474,7 @@ class SshLog implements LifecycleListener {
|
||||
}
|
||||
|
||||
private long extractCreated(final Context ctx) {
|
||||
return (ctx != null) ? ctx.created : System.currentTimeMillis();
|
||||
return (ctx != null) ? ctx.created : TimeUtil.nowMs();
|
||||
}
|
||||
|
||||
private CurrentUser extractCurrentUser(final Context ctx) {
|
||||
|
@ -23,6 +23,7 @@ import com.google.gerrit.server.config.RequestScopedReviewDbProvider;
|
||||
import com.google.gerrit.server.util.RequestContext;
|
||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
||||
import com.google.gerrit.server.util.ThreadLocalRequestScopePropagator;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Key;
|
||||
@ -165,7 +166,7 @@ class SshScope {
|
||||
}
|
||||
|
||||
Context newContext(SchemaFactory<ReviewDb> sf, SshSession s, String cmd) {
|
||||
return new Context(sf, s, cmd, System.currentTimeMillis());
|
||||
return new Context(sf, s, cmd, TimeUtil.nowMs());
|
||||
}
|
||||
|
||||
private Context newContinuingContext(Context ctx) {
|
||||
|
@ -16,6 +16,7 @@ package com.google.gerrit.sshd.commands;
|
||||
|
||||
import com.google.gerrit.common.Version;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gwtorm.jdbc.JdbcSchema;
|
||||
@ -354,7 +355,7 @@ public class QueryShell {
|
||||
}
|
||||
|
||||
private void executeStatement(final String sql) {
|
||||
final long start = System.currentTimeMillis();
|
||||
final long start = TimeUtil.nowMs();
|
||||
final boolean hasResultSet;
|
||||
try {
|
||||
hasResultSet = statement.execute(sql);
|
||||
@ -374,7 +375,7 @@ public class QueryShell {
|
||||
|
||||
} else {
|
||||
final int updateCount = statement.getUpdateCount();
|
||||
final long ms = System.currentTimeMillis() - start;
|
||||
final long ms = TimeUtil.nowMs() - start;
|
||||
switch (outputFormat) {
|
||||
case JSON_SINGLE:
|
||||
case JSON: {
|
||||
@ -490,7 +491,7 @@ public class QueryShell {
|
||||
tail = new JsonObject();
|
||||
tail.addProperty("type", "query-stats");
|
||||
tail.addProperty("rowCount", rowCnt);
|
||||
final long ms = System.currentTimeMillis() - start;
|
||||
final long ms = TimeUtil.nowMs() - start;
|
||||
tail.addProperty("runTimeMilliseconds", ms);
|
||||
}
|
||||
|
||||
@ -629,7 +630,7 @@ public class QueryShell {
|
||||
|
||||
if (start != 0) {
|
||||
final int rowCount = rows.size();
|
||||
final long ms = System.currentTimeMillis() - start;
|
||||
final long ms = TimeUtil.nowMs() - start;
|
||||
println("(" + rowCount + (rowCount == 1 ? " row" : " rows")
|
||||
+ "; " + ms + " ms)");
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.google.gerrit.server.cache.h2.H2CacheImpl;
|
||||
import com.google.gerrit.server.config.SitePath;
|
||||
import com.google.gerrit.server.git.WorkQueue;
|
||||
import com.google.gerrit.server.git.WorkQueue.Task;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshDaemon;
|
||||
import com.google.inject.Inject;
|
||||
@ -59,7 +60,7 @@ final class ShowCaches extends CacheCommand {
|
||||
static class StartupListener implements LifecycleListener {
|
||||
@Override
|
||||
public void start() {
|
||||
serverStarted = System.currentTimeMillis();
|
||||
serverStarted = TimeUtil.nowMs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -270,7 +271,7 @@ final class ShowCaches extends CacheCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
long now = TimeUtil.nowMs();
|
||||
Collection<IoSession> list = acceptor.getManagedSessions().values();
|
||||
long oldest = now;
|
||||
for (IoSession s : list) {
|
||||
|
@ -19,6 +19,7 @@ import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.util.IdGenerator;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
import com.google.gerrit.sshd.SshDaemon;
|
||||
@ -94,7 +95,7 @@ final class ShowConnections extends SshCommand {
|
||||
|
||||
hostNameWidth = wide ? Integer.MAX_VALUE : columns - 9 - 9 - 10 - 32;
|
||||
|
||||
final long now = System.currentTimeMillis();
|
||||
final long now = TimeUtil.nowMs();
|
||||
stdout.print(String.format("%-8s %8s %8s %-15s %s\n", //
|
||||
"Session", "Start", "Idle", "User", "Remote Host"));
|
||||
stdout.print("--------------------------------------------------------------\n");
|
||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.server.git.WorkQueue.Task;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.util.IdGenerator;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.sshd.AdminHighPriorityCommand;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
@ -102,7 +103,7 @@ final class ShowQueue extends SshCommand {
|
||||
+ "--------------------------------\n");
|
||||
|
||||
int numberOfPendingTasks = 0;
|
||||
final long now = System.currentTimeMillis();
|
||||
final long now = TimeUtil.nowMs();
|
||||
final boolean viewAll = currentUser.getCapabilities().canViewQueue();
|
||||
|
||||
for (final Task<?> task : pending) {
|
||||
@ -186,7 +187,7 @@ final class ShowQueue extends SshCommand {
|
||||
}
|
||||
|
||||
private static String startTime(final Date when) {
|
||||
return format(when, System.currentTimeMillis() - when.getTime());
|
||||
return format(when, TimeUtil.nowMs() - when.getTime());
|
||||
}
|
||||
|
||||
private static String format(final Date when, final long timeFromNow) {
|
||||
|
25
lib/joda/BUCK
Normal file
25
lib/joda/BUCK
Normal file
@ -0,0 +1,25 @@
|
||||
include_defs('//lib/maven.defs')
|
||||
|
||||
EXCLUDE = [
|
||||
'META-INF/LICENSE.txt',
|
||||
'META-INF/NOTICE.txt',
|
||||
]
|
||||
|
||||
maven_jar(
|
||||
name = 'joda-time',
|
||||
id = 'joda-time:joda-time:2.3',
|
||||
sha1 = '56498efd17752898cfcc3868c1b6211a07b12b8f',
|
||||
deps = [':joda-convert'],
|
||||
license = 'Apache2.0',
|
||||
exclude = EXCLUDE,
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = 'joda-convert',
|
||||
id = 'org.joda:joda-convert:1.2',
|
||||
bin_sha1 = '35ec554f0cd00c956cc69051514d9488b1374dec',
|
||||
license = 'Apache2.0',
|
||||
exclude = EXCLUDE,
|
||||
visibility = ['//lib/joda:joda-time'],
|
||||
)
|
Loading…
Reference in New Issue
Block a user