Merge branch 'stable-3.0'

* stable-3.0:
  ReviewersUtil: Increase multiplier for candidate list to 3
  Add missing 'Allow content merges' section title in project config documentation
  Fix placement of footer and searchbox in config-project-config.txt
  AbstractQueryChangesTest: Open TestRepository in try-with-resource
  TestRepository: Fix resource leak flagged by Eclipse
  Update git submodules
  Update git submodules
  Accept more than one endpoint from the same plugin
  mvn.py: Explicitly specify version in mvn deploy command
  Add missing 'Allow content merges' section title in project config documentation
  Allow to disable log file compression
  Allow to disable log file rotation
  SystemLog: Don't keep Config as a member
  Remove mention of the offline migrator being in 3.0
  AccountIT#deletePreferredEmail: Fix flakiness
  gerrit.sh: Fix PID definition
  Upgrade gitiles to 0.2-9
  Use Provider<PersonIdent> in CreateProject @Singleton
  AccountIT: Add test for deleting preferred email
  AccountIT: Add test coverage of adding an email and setting preferred

Change-Id: I76b25cf1201d13025fa566b893c3fd02fbf212a0
diff --git a/Documentation/config-project-config.txt b/Documentation/config-project-config.txt
index 6b0c7cf..451e093 100644
--- a/Documentation/config-project-config.txt
+++ b/Documentation/config-project-config.txt
@@ -473,13 +473,6 @@
 You can read more about the +rules.pl+ file and the prolog rules on
 link:prolog-cookbook.html[the Prolog cookbook page].
 
-GERRIT
-------
-Part of link:index.html[Gerrit Code Review]
-
-SEARCHBOX
----------
-
 [[submit-type]]
 === Submit Type
 
@@ -569,5 +562,13 @@
 the important distinction that Rebase Always does not ignore dependencies.
 
 [[content_merge]]
+=== Allow content merges
 If `Allow content merges` is enabled, Gerrit will try
 to do a content merge when a path conflict occurs.
+
+GERRIT
+------
+Part of link:index.html[Gerrit Code Review]
+
+SEARCHBOX
+---------
diff --git a/Documentation/note-db.txt b/Documentation/note-db.txt
index c7e21f1..308e045 100644
--- a/Documentation/note-db.txt
+++ b/Documentation/note-db.txt
@@ -38,9 +38,9 @@
   migrated to NoteDb. In other words, if you use
   link:https://gerrit-review.googlesource.com/[gerrit-review], you're already
   using NoteDb.
-- NoteDb is the only database format supported by Gerrit 3.0. The offline
-  change data migration tool is included in Gerrit 3.0, but online
-  migration is only available in the 2.x line.
+- NoteDb is the only database format supported by Gerrit 3.0. The change data
+  migration tools are only included in Gerrit 2.15 and 2.16; they are not
+  available in 3.0.
 
 For an example NoteDb change, poke around at this one:
 ----
@@ -114,10 +114,10 @@
 * Much faster than online; can use all available CPUs, since no live traffic
   needs to be served.
 * No degraded performance of live servers due to writing data to 2 locations.
-* Available in both Gerrit 2.x and 3.0.
 
 *Disadvantages*
 
+* Available in Gerrit 2.15 and 2.16 only.
 * May require substantial downtime; takes about twice as long as an
   link:pgm-reindex.html[offline reindex]. (In fact, one of the migration steps is a
   full reindex, so it can't possibly take less time.)
diff --git a/WORKSPACE b/WORKSPACE
index 0d3f9ce..cd49c0b 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -726,7 +726,7 @@
     sha1 = "f7be08ec23c21485b9b5a1cf1654c2ec8c58168d",
 )
 
-GITILES_VERS = "0.2-8"
+GITILES_VERS = "0.2-9"
 
 GITILES_REPO = GERRIT
 
@@ -735,14 +735,14 @@
     artifact = "com.google.gitiles:blame-cache:" + GITILES_VERS,
     attach_source = False,
     repository = GITILES_REPO,
-    sha1 = "714fd1d98d02cd8898532ef5169f7b23125747d6",
+    sha1 = "8248f6a8b0863990fe519e9d0de39ec5dc99c189",
 )
 
 maven_jar(
     name = "gitiles-servlet",
     artifact = "com.google.gitiles:gitiles-servlet:" + GITILES_VERS,
     repository = GITILES_REPO,
-    sha1 = "a416e4ac5a0cad04410440d0b2785fa966bc5a0c",
+    sha1 = "cb47a8f1d84645acddfe2945a63ce8ce5c22a53e",
 )
 
 # prettify must match the version used in Gitiles
diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
index f653ef1..7a3fbd4 100644
--- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
@@ -1062,6 +1062,23 @@
   }
 
   @Test
+  public void addEmailAndSetPreferred() throws Exception {
+    String email = "foo.bar@example.com";
+    EmailInput input = new EmailInput();
+    input.email = email;
+    input.noConfirmation = true;
+    input.preferred = true;
+    gApi.accounts().self().addEmail(input);
+
+    // Account is reindexed twice; once on adding the new email,
+    // and then again on setting the email preferred.
+    accountIndexedCounter.assertReindexOf(admin, 2);
+
+    String preferred = gApi.accounts().self().get().email;
+    assertThat(preferred).isEqualTo(email);
+  }
+
+  @Test
   public void deleteEmail() throws Exception {
     String email = "foo.bar@example.com";
     EmailInput input = newEmailInput(email);
@@ -1079,6 +1096,29 @@
   }
 
   @Test
+  public void deletePreferredEmail() throws Exception {
+    String email = "foo.bar.baz@example.com";
+    EmailInput input = new EmailInput();
+    input.email = email;
+    input.noConfirmation = true;
+    input.preferred = true;
+    gApi.accounts().self().addEmail(input);
+
+    // Account is reindexed twice; once on adding the new email,
+    // and then again on setting the email preferred.
+    accountIndexedCounter.assertReindexOf(admin, 2);
+
+    assertThat(gApi.accounts().self().get().email).isEqualTo(email);
+
+    accountIndexedCounter.clear();
+    gApi.accounts().self().deleteEmail(input.email);
+    accountIndexedCounter.assertReindexOf(admin);
+
+    requestScopeOperations.resetCurrentApiUser();
+    assertThat(getEmails()).doesNotContain(email);
+  }
+
+  @Test
   public void deleteEmailFromCustomExternalIdSchemes() throws Exception {
     String email = "foo.bar@example.com";
     String extId1 = "foo:bar";
diff --git a/plugins/replication b/plugins/replication
index b447688..fe57866 160000
--- a/plugins/replication
+++ b/plugins/replication
@@ -1 +1 @@
-Subproject commit b44768838ff462b373e932d3d5c340612e28f940
+Subproject commit fe578665e97e9d7b082bce0b62879b598305729b
diff --git a/resources/com/google/gerrit/pgm/init/gerrit.sh b/resources/com/google/gerrit/pgm/init/gerrit.sh
index c32a181..143e028 100755
--- a/resources/com/google/gerrit/pgm/init/gerrit.sh
+++ b/resources/com/google/gerrit/pgm/init/gerrit.sh
@@ -434,8 +434,8 @@
       fi
     fi
 
+    PID=`cat "$GERRIT_PID"`
     if test $UID = 0; then
-        PID=`cat "$GERRIT_PID"`
         if test -f "/proc/${PID}/oom_score_adj" ; then
             echo -1000 > "/proc/${PID}/oom_score_adj"
         else
diff --git a/tools/maven/mvn.py b/tools/maven/mvn.py
index d47d027..59a5efb 100755
--- a/tools/maven/mvn.py
+++ b/tools/maven/mvn.py
@@ -46,6 +46,7 @@
     cmd = [
         'mvn',
         'gpg:sign-and-deploy-file',
+        '-Dversion=%s' % args.v,
         '-DrepositoryId=%s' % args.repository,
         '-Durl=%s' % args.url,
     ]