Only validate non-empty queries that do not match all changes Empty and * queries will just make the reviewer filter apply in later processing. So they are always valid. This change is a latency improvement since trying to construct a query with `*` on servers that have account visibility checking will cause Gerrit to lookup many accounts (through ChangeQueryBuilder -> default -> parseAccount -> AccountResolver -> check). Google-Bug: b/267202984 Change-Id: If9f5e879b05044e23b527d65838da6900a378956
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewers/config/ReviewerFilterCollection.java b/src/main/java/com/googlesource/gerrit/plugins/reviewers/config/ReviewerFilterCollection.java index 91b49e8..c0babc4 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/reviewers/config/ReviewerFilterCollection.java +++ b/src/main/java/com/googlesource/gerrit/plugins/reviewers/config/ReviewerFilterCollection.java
@@ -18,6 +18,7 @@ import static com.googlesource.gerrit.plugins.reviewers.config.ForProject.KEY_REVIEWER; import static com.googlesource.gerrit.plugins.reviewers.config.ForProject.SECTION_FILTER; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -89,7 +90,9 @@ * ValidationError to the ValidationError.Sink and returns the error. */ private Optional<String> checkForErrors(String filterQuery) { try { - queryValidator.validateQuery(filterQuery); + if (!Strings.isNullOrEmpty(filterQuery) && !"*".equals(filterQuery)) { + queryValidator.validateQuery(filterQuery); + } } catch (QueryParseException qpe) { validationErrorSink.ifPresent(ves -> ves.error(ValidationError.create(qpe.getMessage()))); return Optional.of(qpe.getMessage());