Merge branch 'stable-2.16'

* stable-2.16:
  Add missing license/copyright headers
  Use '-' instead of spaces for owners label
  Removed redundant PLUGIN_DEPS from BUILD
  Format with GJF 1.7
  Format with GJF 1.7
  Add integration test for owners-autoassign
  Prevent infinite event processing with NoteDb
  Look for gerrit:/username: schemes for username
  Get rid of references to ReviewDb

Change-Id: Ie4e2420eb3cec37eaee83b2e8085d8ff25ffe4b7
diff --git a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java
index 3eb5754..22e3db8 100644
--- a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java
+++ b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java
@@ -50,11 +50,8 @@
   private final GerritApi api;
 
   private final PatchListCache patchListCache;
-
   private final GitRepositoryManager repositoryManager;
-
   private final Accounts accounts;
-
   private final ReviewerManager reviewerManager;
 
   @Inject
diff --git a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java
index efb9910..4a16316 100644
--- a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java
+++ b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java
@@ -25,7 +25,6 @@
 import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.server.util.ManualRequestContext;
 import com.google.gerrit.server.util.OneOffRequestContext;
-import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import java.util.ArrayList;
@@ -63,7 +62,7 @@
         }
         gApi.changes().id(changeInfo.id).current().review(in);
       }
-    } catch (RestApiException | OrmException e) {
+    } catch (RestApiException e) {
       log.error("Couldn't add reviewers to the change", e);
       throw new ReviewerManagerException(e);
     }
diff --git a/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java b/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java
index 106a91a..b5c1f90 100644
--- a/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java
+++ b/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java
@@ -18,7 +18,6 @@
 import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_MAILTO;
 import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USERNAME;
 
-import com.google.gerrit.common.errors.NoSuchGroupException;
 import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.reviewdb.client.Account.Id;
 import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -33,7 +32,6 @@
 import com.google.gerrit.server.project.NoSuchProjectException;
 import com.google.gerrit.server.util.ManualRequestContext;
 import com.google.gerrit.server.util.OneOffRequestContext;
-import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 import java.io.IOException;
 import java.util.Collections;
@@ -95,7 +93,7 @@
       return groupMembers.listAccounts(group.get().getGroupUUID(), null).stream()
           .map(Account::getId)
           .collect(Collectors.toSet());
-    } catch (NoSuchProjectException | OrmException | IOException e) {
+    } catch (NoSuchProjectException | IOException e) {
       log.error("Unable to list accounts in group " + group, e);
       return Collections.emptySet();
     }
@@ -103,7 +101,7 @@
 
   private Set<Account.Id> findUserOrEmail(String nameOrEmail) {
     try (ManualRequestContext ctx = oneOffRequestContext.open()) {
-      Set<Id> accountIds = resolver.findAll(nameOrEmail);
+      Set<Id> accountIds = resolver.resolve(nameOrEmail).asIdSet();
       if (accountIds.isEmpty()) {
         log.warn("User '{}' does not resolve to any account.", nameOrEmail);
         return accountIds;
@@ -134,7 +132,7 @@
       }
 
       return accountIds;
-    } catch (OrmException | IOException | ConfigInvalidException e) {
+    } catch (IOException | ConfigInvalidException e) {
       log.error("Error trying to resolve user " + nameOrEmail, e);
       return Collections.emptySet();
     }
diff --git a/owners-common/src/main/java/com/googlesource/gerrit/owners/common/ConfigurationParser.java b/owners-common/src/main/java/com/googlesource/gerrit/owners/common/ConfigurationParser.java
index 2f5c5c0..dcdd9f7 100644
--- a/owners-common/src/main/java/com/googlesource/gerrit/owners/common/ConfigurationParser.java
+++ b/owners-common/src/main/java/com/googlesource/gerrit/owners/common/ConfigurationParser.java
@@ -43,7 +43,7 @@
       final OwnersConfig ret = new OwnersConfig();
       JsonNode jsonNode = new ObjectMapper(new YAMLFactory()).readValue(yamlBytes, JsonNode.class);
       Boolean inherited =
-          Optional.ofNullable(jsonNode.get("inherited")).map(JsonNode::asBoolean).orElse(false);
+          Optional.ofNullable(jsonNode.get("inherited")).map(JsonNode::asBoolean).orElse(true);
       ret.setInherited(inherited);
       addClassicMatcher(jsonNode, ret);
       addMatchers(jsonNode, ret);