WebAppInitializer: Move plugin modules loading to after the index one

And load the online upgrader module, if configured so, right after the
plugin module. This change aligns that specific module loading ordering
with the Daemon class, which already implements the right loading order.

This commit basically adjusts what was just previously done for the
WebAppInitializer class, alongside Daemon, in parent commit 020758e.

Bug: Issue 10082
Change-Id: I6fd4379e234e7b707cdfba3cadf3dc58ef1cedb7
diff --git a/gerrit-war/src/main/java/com/google/gerrit/httpd/WebAppInitializer.java b/gerrit-war/src/main/java/com/google/gerrit/httpd/WebAppInitializer.java
index 9ccc23c..28c9137 100644
--- a/gerrit-war/src/main/java/com/google/gerrit/httpd/WebAppInitializer.java
+++ b/gerrit-war/src/main/java/com/google/gerrit/httpd/WebAppInitializer.java
@@ -330,8 +330,6 @@
     modules.add(cfgInjector.getInstance(MailReceiver.Module.class));
     modules.add(new SmtpEmailSender.Module());
     modules.add(new SignedTokenEmailTokenVerifier.Module());
-    modules.add(new PluginModule());
-    modules.add(new PluginRestApiModule());
     modules.add(new RestCacheAdminModule());
     modules.add(new GpgModule(config));
     modules.add(new StartupChecks.Module());
@@ -340,6 +338,12 @@
     // work queue can get stuck waiting on index futures that will never return.
     modules.add(createIndexModule());
 
+    modules.add(new PluginModule());
+    if (VersionManager.getOnlineUpgrade(config)) {
+      modules.add(new OnlineUpgrader.Module());
+    }
+
+    modules.add(new PluginRestApiModule());
     modules.add(new WorkQueue.Module());
     modules.add(
         new CanonicalWebUrlModule() {
@@ -407,9 +411,6 @@
     }
     modules.add(H2CacheBasedWebSession.module());
     modules.add(new HttpPluginModule());
-    if (VersionManager.getOnlineUpgrade(config)) {
-      modules.add(new OnlineUpgrader.Module());
-    }
 
     AuthConfig authConfig = cfgInjector.getInstance(AuthConfig.class);
     if (authConfig.getAuthType() == AuthType.OPENID) {