Set the timestamp after the evaluation is done
The goal of the timestamp is to reduce the amount of evaluation based on
the expireTimeRecheck. Setting it when the evaluation is queued is wrong
given the evaluation can be executed way after it was queued when worker
threads are busy.
Change-Id: Ifeb1cfe7b90d343dc410be1990a4a5320118e591
diff --git a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java
index 67d216f..07450c4 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java
@@ -122,6 +122,7 @@
if (queuedEvaluationTasks.add(evaluationTask)) {
try {
executor.execute(evaluationTask);
+ timestamps.put(repositoryPath, System.currentTimeMillis());
} finally {
queuedEvaluationTasks.remove(evaluationTask);
}
@@ -130,12 +131,7 @@
}
private boolean lastCheckExpired(String repositoryPath) {
- long now = System.currentTimeMillis();
- if (!timestamps.containsKey(repositoryPath)
- || now >= timestamps.get(repositoryPath) + expireTime) {
- timestamps.put(repositoryPath, now);
- return true;
- }
- return false;
+ return !timestamps.containsKey(repositoryPath)
+ || System.currentTimeMillis() >= timestamps.get(repositoryPath) + expireTime;
}
}