Merge branch 'stable-3.5' into stable-3.6

* stable-3.5:
  Bump version to v3.5.4.4
  Bump version to v3.4.8.6
  Consider robot comments as mutable ref for validation
  Introduce isUpToDateUnchecked for silent global-refdb checks
  Add Bazel build instructions
  Define the artifact as Gerrit plugin
  Set version to v3.5.4.3

Change-Id: Iba6328e535a9cc612f0d5a57f0f51ffed64ec6cd
diff --git a/pom.xml b/pom.xml
index af54b41..0cf8865 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
 
     <groupId>com.gerritforge</groupId>
     <artifactId>global-refdb</artifactId>
-    <version>3.5.4.4</version>
+    <version>3.6.3.3</version>
     <packaging>jar</packaging>
 
     <name>global-refdb</name>
@@ -38,7 +38,7 @@
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <gerrit.version>3.5.4</gerrit.version>
+        <gerrit.version>3.6.3</gerrit.version>
     </properties>
 
     <dependencies>
@@ -81,7 +81,7 @@
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>3.6.1</version>
                 <configuration>
-                    <source>1.8</source>
+                    <source>11</source>
                     <target>11</target>
                 </configuration>
             </plugin>
diff --git a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/BatchRefUpdateValidator.java b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/BatchRefUpdateValidator.java
index 0fe5ad5..22aae61 100644
--- a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/BatchRefUpdateValidator.java
+++ b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/BatchRefUpdateValidator.java
@@ -150,7 +150,7 @@
               .collect(Collectors.joining(", "));
       Exception firstFailureException = refsFailures.get(0).exception;
 
-      logger.atSevere().withCause(firstFailureException).log(allFailuresMessage);
+      logger.atSevere().withCause(firstFailureException).log("%s", allFailuresMessage);
       throw new IOException(allFailuresMessage, firstFailureException);
     }
 
@@ -162,17 +162,15 @@
       } catch (Exception e) {
         List<ReceiveCommand> receiveCommands = batchRefUpdate.getCommands();
         logger.atWarning().withCause(e).log(
-            String.format(
-                "Batch ref-update failing because of failure during the global refdb update. Set all commands Result to LOCK_FAILURE [%d]",
-                receiveCommands.size()));
+            "Batch ref-update failing because of failure during the global refdb update. Set all commands Result to LOCK_FAILURE [%d]",
+            receiveCommands.size());
         rollback(delegateUpdateRollback, finalRefsToUpdate, receiveCommands);
       }
     } catch (OutOfSyncException e) {
       List<ReceiveCommand> receiveCommands = batchRefUpdate.getCommands();
       logger.atWarning().withCause(e).log(
-          String.format(
-              "Batch ref-update failing because node is out of sync with the shared ref-db. Set all commands Result to LOCK_FAILURE [%d]",
-              receiveCommands.size()));
+          "Batch ref-update failing because node is out of sync with the shared ref-db. Set all commands Result to LOCK_FAILURE [%d]",
+          receiveCommands.size());
       receiveCommands.forEach((command) -> command.setResult(ReceiveCommand.Result.LOCK_FAILURE));
     }
   }
diff --git a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/LibModuleLogFile.java b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/LibModuleLogFile.java
index c2858b4..7f10ef4 100644
--- a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/LibModuleLogFile.java
+++ b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/LibModuleLogFile.java
@@ -33,10 +33,11 @@
    * @see org.apache.log4j.PatternLayout
    */
   public LibModuleLogFile(SystemLog systemLog, String logName, Layout layout) {
-    AsyncAppender asyncAppender = systemLog.createAsyncAppender(logName, layout, true, true);
     Logger logger = LogManager.getLogger(logName);
-    logger.removeAppender(logName);
-    logger.addAppender(asyncAppender);
-    logger.setAdditivity(false);
+    if (logger.getAppender(logName) == null) {
+      AsyncAppender asyncAppender = systemLog.createAsyncAppender(logName, layout, true, true);
+      logger.addAppender(asyncAppender);
+      logger.setAdditivity(false);
+    }
   }
 }
diff --git a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/RefUpdateValidator.java b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/RefUpdateValidator.java
index 5972ad3..c86a346 100644
--- a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/RefUpdateValidator.java
+++ b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/RefUpdateValidator.java
@@ -160,16 +160,15 @@
   private Boolean isRefToBeIgnored(String refName) {
     Boolean isRefToBeIgnored =
         ignoredRefs.stream().anyMatch(ignoredRefPrefix -> refName.startsWith(ignoredRefPrefix));
-    logger.atFine().log("Is ref to be ignored? " + isRefToBeIgnored);
+    logger.atFine().log("Is project version update? %s", isRefToBeIgnored);
     return isRefToBeIgnored;
   }
 
   private <T extends Throwable> void softFailBasedOnEnforcement(T e, EnforcePolicy policy)
       throws T {
     logger.atWarning().withCause(e).log(
-        String.format(
-            "Failure while running with policy enforcement %s. Error message: %s",
-            policy, e.getMessage()));
+        "Failure while running with policy enforcement %s. Error message: %s",
+        policy, e.getMessage());
     if (policy == EnforcePolicy.REQUIRED) {
       throw e;
     }
@@ -177,7 +176,7 @@
 
   protected Boolean isGlobalProject(String projectName) {
     Boolean isGlobalProject = projectsFilter.matches(projectName);
-    logger.atFine().log("Is global project? " + isGlobalProject);
+    logger.atFine().log("Is global project? %s", isGlobalProject);
     return isGlobalProject;
   }
 
@@ -200,14 +199,13 @@
           result = RefUpdate.Result.LOCK_FAILURE;
         }
         logger.atSevere().withCause(e).log(
-            String.format(
-                "Failed to update global refdb, the local refdb has been rolled back: %s",
-                e.getMessage()));
+            "Failed to update global refdb, the local refdb has been rolled back: %s",
+            e.getMessage());
       }
       return result;
     } catch (OutOfSyncException e) {
       logger.atWarning().withCause(e).log(
-          String.format("Local node is out of sync with ref-db: %s", e.getMessage()));
+          "Local node is out of sync with ref-db: %s", e.getMessage());
 
       return RefUpdate.Result.LOCK_FAILURE;
     }
@@ -232,10 +230,8 @@
               Project.nameKey(projectName), refPair.compareRef, refPair.putValue);
     } catch (GlobalRefDbSystemError e) {
       logger.atWarning().withCause(e).log(
-          "Not able to persist the data in Zookeeper for project '{}' and ref '{}', message: {}",
-          projectName,
-          refPair.getName(),
-          e.getMessage());
+          "Not able to persist the data in Zookeeper for project '%s' and ref '%s', message: %s",
+          projectName, refPair.getName(), e.getMessage());
       throw e;
     }
 
diff --git a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/SharedRefDbGitRepositoryManager.java b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/SharedRefDbGitRepositoryManager.java
index 763aeb4..24bed90 100644
--- a/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/SharedRefDbGitRepositoryManager.java
+++ b/src/main/java/com/gerritforge/gerrit/globalrefdb/validation/SharedRefDbGitRepositoryManager.java
@@ -25,7 +25,7 @@
 import com.google.inject.Singleton;
 import com.google.inject.name.Named;
 import java.io.IOException;
-import java.util.SortedSet;
+import java.util.NavigableSet;
 import org.eclipse.jgit.errors.RepositoryNotFoundException;
 import org.eclipse.jgit.lib.Repository;
 
@@ -110,7 +110,7 @@
   }
 
   @Override
-  public SortedSet<Project.NameKey> list() {
+  public NavigableSet<Project.NameKey> list() {
     return repositoryManager().list();
   }
 
diff --git a/src/test/java/com/gerritforge/gerrit/globalrefdb/validation/dfsrefdb/RefUpdateStub.java b/src/test/java/com/gerritforge/gerrit/globalrefdb/validation/dfsrefdb/RefUpdateStub.java
index e78ba6d..2da186b 100644
--- a/src/test/java/com/gerritforge/gerrit/globalrefdb/validation/dfsrefdb/RefUpdateStub.java
+++ b/src/test/java/com/gerritforge/gerrit/globalrefdb/validation/dfsrefdb/RefUpdateStub.java
@@ -15,7 +15,7 @@
 package com.gerritforge.gerrit.globalrefdb.validation.dfsrefdb;
 
 import java.io.IOException;
-import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.lang3.NotImplementedException;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.RefDatabase;