Introduce isUpToDateUnchecked for silent global-refdb checks
Allow the implementations of global-refdb to have an method for
checking the consistency of the local refs without throwing any
exception, logging any warning or initiate a transaction.
Also amend the version of the libModule to v3.4.8.5.
Change-Id: I2d4acbae2eec05158ae09fa82d1e0e06494305b9
diff --git a/pom.xml b/pom.xml
index 701a08b..db24f7f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>com.gerritforge</groupId>
<artifactId>global-refdb</artifactId>
- <version>3.4.8.4</version>
+ <version>3.4.8.5</version>
<packaging>jar</packaging>
<name>global-refdb</name>
diff --git a/src/main/java/com/gerritforge/gerrit/globalrefdb/GlobalRefDatabase.java b/src/main/java/com/gerritforge/gerrit/globalrefdb/GlobalRefDatabase.java
index dbc52e8..df1e20a 100644
--- a/src/main/java/com/gerritforge/gerrit/globalrefdb/GlobalRefDatabase.java
+++ b/src/main/java/com/gerritforge/gerrit/globalrefdb/GlobalRefDatabase.java
@@ -33,6 +33,26 @@
boolean isUpToDate(Project.NameKey project, Ref ref) throws GlobalRefDbLockException;
/**
+ * Check in global ref-db if ref is up-to-date, without locking, warnings or checked exceptions.
+ *
+ * <p>Differently from the regular {@link #isUpToDate(com.google.gerrit.entities.Project.NameKey,
+ * Ref)} this method is suitable for checking the status of the local-ref against the global-refdb
+ * without having any intention to update its value in a transaction.
+ *
+ * <p>The concrete implementations of GlobalRefDatabase must provide a specific implementation for
+ * this method that does not create any warnings in the logs.
+ *
+ * @param project project name of the ref
+ * @param ref to be checked against global ref-db
+ * @return true if it is; false otherwise
+ * @since 3.4.8.5
+ */
+ default boolean isUpToDateUnchecked(Project.NameKey project, Ref ref) {
+ throw new UnsupportedOperationException(
+ "isUpToDateUnchecked() is not supported by " + this.getClass().getName());
+ }
+
+ /**
* Compare a reference, and put if it is up-to-date with the current.
*
* <p>Two reference match if and only if they satisfy the following: