SuperManifestRefUpdatedListener: inline the update method

The update() method has a boolean parameter to let the exceptions pass
through or not. This makes the exception handling unnecessarily
difficult to read. The method is only called from two places (with the
param set as true and false on each).

Inline the #update() method to the callers. This moves the exception
handling to the same level for both paths (REST call/plugin call) and
makes clearer what happens on exceptions: the REST call let the
exception go and stops, the plugin still tries with remaning confs.

Change-Id: I17933da33437dea4cbbe179b1ef4b6ffeb0655cf
diff --git a/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java b/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java
index 5767376..57ee1b6 100644
--- a/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java
+++ b/java/com/googlesource/gerrit/plugins/supermanifest/SuperManifestRefUpdatedListener.java
@@ -272,10 +272,28 @@
       }
       return;
     }
-    try {
-      update(event.getProjectName(), event.getRefName(), true);
-    } catch (Exception e) {
-      // no exceptions since we set continueOnError = true.
+
+    List<ConfigEntry> relevantConfigs =
+        findRelevantConfigs(event.getProjectName(), event.getRefName());
+    for (ConfigEntry relevantConfig : relevantConfigs) {
+      try {
+        updateForConfig(relevantConfig, event.getRefName());
+      } catch (ConfigInvalidException | IOException | GitAPIException e) {
+        // We only want the trace up to here. We could recurse into the exception, but this at least
+        // trims the very common jgit.gitrepo.RepoCommand.RemoteUnavailableException.
+        StackTraceElement here = Thread.currentThread().getStackTrace()[1];
+        e.setStackTrace(trimStack(e.getStackTrace(), here));
+
+        // We are in an asynchronously called listener, so there is no user action to give
+        // feedback to. We log the error, but it would be nice if we could surface these logs
+        // somewhere.  Perhaps we could store these as commits in some special branch (but in
+        // what repo?).
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        e.printStackTrace(pw);
+        error(
+            "update for %s (ref %s) failed: %s", relevantConfig.toString(), event.getRefName(), sw);
+      }
     }
   }
 
@@ -291,16 +309,16 @@
         identifiedUser.get().getAccountId().get(),
         configurationToString());
 
-    update(resource.getProjectState().getProject().getName(), resource.getRef(), false);
+    List<ConfigEntry> relevantConfigs =
+        findRelevantConfigs(resource.getProjectState().getProject().getName(), resource.getRef());
+    for (ConfigEntry config : relevantConfigs) {
+      updateForConfig(config, resource.getRef());
+    }
     return Response.none();
   }
 
-  /**
-   * Updates projects in response to update in given project/ref. Only throws exceptions if
-   * continueOnError is false.
-   */
-  private void update(String project, String refName, boolean continueOnError)
-      throws IOException, GitAPIException, ConfigInvalidException {
+  private List<ConfigEntry> findRelevantConfigs(String project, String refName) {
+    List<ConfigEntry> relevantConfigs = new ArrayList<>();
     for (ConfigEntry c : config) {
       if (!c.srcRepoKey.get().equals(project)) {
         continue;
@@ -317,28 +335,9 @@
       if (c.srcRefsExcluded.contains(refName)) {
         continue;
       }
-
-      try {
-        updateForConfig(c, refName);
-      } catch (ConfigInvalidException | IOException | GitAPIException e) {
-        if (!continueOnError) {
-          throw e;
-        }
-        // We only want the trace up to here. We could recurse into the exception, but this at least
-        // trims the very common jgit.gitrepo.RepoCommand.RemoteUnavailableException.
-        StackTraceElement here = Thread.currentThread().getStackTrace()[1];
-        e.setStackTrace(trimStack(e.getStackTrace(), here));
-
-        // We are in an asynchronously called listener, so there is no user action to give
-        // feedback to. We log the error, but it would be nice if we could surface these logs
-        // somewhere.  Perhaps we could store these as commits in some special branch (but in
-        // what repo?).
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        e.printStackTrace(pw);
-        error("update for %s (ref %s) failed: %s", c.toString(), refName, sw);
-      }
+      relevantConfigs.add(c);
     }
+    return relevantConfigs;
   }
 
   private void updateForConfig(ConfigEntry c, String refName)