Handle missing unknown during loading of change notes

Occasionally, some of the changes are failing when they are tried to
be reindexed on the second node because of the:

  POST /plugins/high-availability/index/change/<project>~<change-num>

fails because of a org.eclipse.jgit.errors.MissingObjectException.

The code path assumes that the change notes can be loaded or is not
present yet (NFS shared driver). What is missing is to handle
StorageException for not completly available change notes on second
node.

Bug: Issue 14461
Change-Id: If90f684d4595cbe5fc205e12da0bd62398772279
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedIndexChangeHandler.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedIndexChangeHandler.java
index 064783c..91e5a02 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedIndexChangeHandler.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedIndexChangeHandler.java
@@ -21,6 +21,7 @@
 import com.ericsson.gerrit.plugins.highavailability.index.ForwardedIndexExecutor;
 import com.google.common.base.Splitter;
 import com.google.gerrit.entities.Change;
+import com.google.gerrit.exceptions.StorageException;
 import com.google.gerrit.server.index.change.ChangeIndexer;
 import com.google.gerrit.server.notedb.ChangeNotes;
 import com.google.gerrit.server.project.NoSuchChangeException;
@@ -74,7 +75,13 @@
       throws IOException {
     try {
       ChangeChecker checker = changeCheckerFactory.create(id);
-      Optional<ChangeNotes> changeNotes = checker.getChangeNotes();
+      Optional<ChangeNotes> changeNotes;
+      try {
+        changeNotes = checker.getChangeNotes();
+      } catch (StorageException e) {
+        log.atWarning().withCause(e).log("Change %s: cannot load change notes", id);
+        changeNotes = Optional.empty();
+      }
       if (changeNotes.isPresent()) {
         ChangeNotes notes = changeNotes.get();
         reindex(notes);