Merge "Bazel: Remove unused jetty-servlets dependency" into stable-3.0
diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt
index 7ab1a81..63a66d5 100644
--- a/Documentation/dev-bazel.txt
+++ b/Documentation/dev-bazel.txt
@@ -158,7 +158,7 @@
 Java docs will be placed in:
 
 ----
-  bazel-genfiles/api.zip
+  bazel-bin/api.zip
 ----
 
 Install {extension,plugin,acceptance-framework}-api to the local
@@ -183,13 +183,13 @@
 The output JAR files for individual plugins will be placed in:
 
 ----
-  bazel-genfiles/plugins/<name>/<name>.jar
+  bazel-bin/plugins/<name>/<name>.jar
 ----
 
 The JAR files will also be packaged in:
 
 ----
-  bazel-genfiles/plugins/core.zip
+  bazel-bin/plugins/core.zip
 ----
 
 To build a specific plugin:
@@ -201,7 +201,7 @@
 The output JAR file will be be placed in:
 
 ----
-  bazel-genfiles/plugins/<name>/<name>.jar
+  bazel-bin/plugins/<name>/<name>.jar
 ----
 
 Note that when building an individual plugin, the `core.zip` package
diff --git a/java/com/google/gerrit/server/query/change/ChangeData.java b/java/com/google/gerrit/server/query/change/ChangeData.java
index 619569f..3cd64b3 100644
--- a/java/com/google/gerrit/server/query/change/ChangeData.java
+++ b/java/com/google/gerrit/server/query/change/ChangeData.java
@@ -832,7 +832,7 @@
   }
 
   public List<SubmitRecord> submitRecords(SubmitRuleOptions options) {
-    List<SubmitRecord> records = submitRecords.get(options);
+    List<SubmitRecord> records = getCachedSubmitRecord(options);
     if (records == null) {
       if (!lazyLoad) {
         return Collections.emptyList();
@@ -845,7 +845,21 @@
 
   @Nullable
   public List<SubmitRecord> getSubmitRecords(SubmitRuleOptions options) {
-    return submitRecords.get(options);
+    return getCachedSubmitRecord(options);
+  }
+
+  private List<SubmitRecord> getCachedSubmitRecord(SubmitRuleOptions options) {
+    List<SubmitRecord> records = submitRecords.get(options);
+    if (records != null) {
+      return records;
+    }
+
+    if (options.allowClosed() && change != null && change.getStatus().isOpen()) {
+      SubmitRuleOptions openSubmitRuleOptions = options.toBuilder().allowClosed(false).build();
+      return submitRecords.get(openSubmitRuleOptions);
+    }
+
+    return null;
   }
 
   public void setSubmitRecords(SubmitRuleOptions options, List<SubmitRecord> records) {
diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
index 60a8290..6131ada 100644
--- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
@@ -1074,6 +1074,7 @@
 
   @Test
   public void deletePreferredEmail() throws Exception {
+    String previous = gApi.accounts().self().get().email;
     String email = "foo.bar.baz@example.com";
     EmailInput input = new EmailInput();
     input.email = email;
@@ -1085,6 +1086,7 @@
     // and then again on setting the email preferred.
     accountIndexedCounter.assertReindexOf(admin, 2);
 
+    // The new preferred email is set
     assertThat(gApi.accounts().self().get().email).isEqualTo(email);
 
     accountIndexedCounter.clear();
@@ -1092,7 +1094,8 @@
     accountIndexedCounter.assertReindexOf(admin);
 
     requestScopeOperations.resetCurrentApiUser();
-    assertThat(getEmails()).doesNotContain(email);
+    assertThat(getEmails()).containsExactly(previous);
+    assertThat(gApi.accounts().self().get().email).isNull();
   }
 
   @Test
diff --git a/plugins/codemirror-editor b/plugins/codemirror-editor
index 3baf62e..2d3f265 160000
--- a/plugins/codemirror-editor
+++ b/plugins/codemirror-editor
@@ -1 +1 @@
-Subproject commit 3baf62e1f12bea107598777a3881455cf39fd8ab
+Subproject commit 2d3f265ab1797d4179cbd6855c937989175d5ce5
diff --git a/plugins/gitiles b/plugins/gitiles
index a58ae0b..2523fc1 160000
--- a/plugins/gitiles
+++ b/plugins/gitiles
@@ -1 +1 @@
-Subproject commit a58ae0ba2c23576a68d457e00aaf0902f41e4bb9
+Subproject commit 2523fc1c0bb7b4f6454e7c5aff2bdd5a8ccad18f
diff --git a/tools/bzl/maven_jar.bzl b/tools/bzl/maven_jar.bzl
index 0ff460b9..0658604 100644
--- a/tools/bzl/maven_jar.bzl
+++ b/tools/bzl/maven_jar.bzl
@@ -145,7 +145,7 @@
     out = ctx.execute(args)
 
     if out.return_code:
-        fail("failed %s: %s" % (" ".join(args), out.stderr))
+        fail("failed %s: %s" % (args, out.stderr))
 
     srcjar = None
     if ctx.attr.src_sha1 or ctx.attr.attach_source:
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 478f448..bfd85ae 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -54,15 +54,19 @@
                 dest='java', help='Post Java 8 support (9)')
 opts.add_option('-e', '--edge_java', action='store',
                 dest='edge_java', help='Post Java 9 support (10|11|...)')
+opts.add_option('--bazel', help='name of the bazel executable',
+                action='store', default='bazel', dest='bazel_exe')
+
 args, _ = opts.parse_args()
 
 batch_option = '--batch' if args.batch else None
 custom_java = args.java
 edge_java = args.edge_java
+bazel_exe = args.bazel_exe
 
 def _build_bazel_cmd(*args):
     build = False
-    cmd = ['bazel']
+    cmd = [bazel_exe]
     if batch_option:
         cmd.append('--batch')
     for arg in args:
@@ -82,7 +86,7 @@
 
 
 def gen_bazel_path(ext_location):
-    bazel = check_output(['which', 'bazel']).strip().decode('UTF-8')
+    bazel = check_output(['which', bazel_exe]).strip().decode('UTF-8')
     with open(path.join(ROOT, ".bazel_path"), 'w') as fd:
         fd.write("output_base=%s\n" % ext_location)
         fd.write("bazel=%s\n" % bazel)