OAK-9517: Incorrect time difference warning
Fix implementation and enable test
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
index c72c991..79bbe09 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
@@ -960,7 +960,7 @@
* @param rootDoc the root document.
* @param clock the clock.
* @param clusterId the local clusterId.
- * @param warnThresholdMillis log a warning when the an external change in
+ * @param warnThresholdMillis log a warning when an external change in
* the future is detected with more than this time difference.
* @throws InterruptedException if the current thread is interrupted while
* waiting. The interrupted status on the current thread is cleared
@@ -974,8 +974,8 @@
Map<Integer, Revision> lastRevMap = checkNotNull(rootDoc).getLastRev();
long externalTime = Utils.getMaxExternalTimestamp(lastRevMap.values(), clusterId);
long localTime = clock.getTime();
- long timeDiff = externalTime - localTime;
- if (timeDiff > 0) {
+ if (externalTime > localTime) {
+ long timeDiff = externalTime - localTime;
double delay = ((double) externalTime - localTime) / 1000d;
String fmt = "Background read will be delayed by %.1f seconds. " +
"Please check system time on cluster nodes.";
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java
index bb3b675..ccc5375 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java
@@ -366,7 +366,6 @@
}
}
- @Ignore("OAK-9517")
@Test
public void noWarnWithSingleClusterId() throws Exception {
Clock c = new Clock.Virtual();