Merge branch 'stable-3.2'

* stable-3.2:
  Adapt to Gerrit v3.2 for Accounts and ProjectCache

Change-Id: I84a31a29bf9b0a9205453803f30ac657316a76bc
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
index 9b234f5..cb71e78 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
@@ -82,7 +82,7 @@
   private final int jobIndex;
   private final ExternalIds externalIds;
   private PullRequestCreateChange createChange;
-  private Project project;
+  private Optional<Project> project;
   private GitJobStatus status;
   private boolean cancelRequested;
   private AccountImporter accountImporter;
@@ -114,11 +114,10 @@
     this.externalIds = externalIds;
   }
 
-  private Project fetchGerritProject(
+  private Optional<Project> fetchGerritProject(
       ProjectCache projectCache, String fetchOrganisation, String fetchRepoName) {
     NameKey projectNameKey = Project.NameKey.parse(fetchOrganisation + "/" + fetchRepoName);
-    ProjectState projectState = projectCache.get(projectNameKey);
-    return projectState.getProject();
+    return projectCache.get(projectNameKey).map(ProjectState::getProject);
   }
 
   @Override
@@ -179,17 +178,19 @@
         GitHubUser gitHubUser = GitHubUser.from(prUser, commitAuthor);
 
         Account.Id pullRequestOwner = getOrRegisterAccount(gitHubUser);
-        Id changeId =
-            createChange.addCommitToChange(
-                project,
-                gitRepo,
-                destinationBranch,
-                pullRequestOwner,
-                revCommit,
-                getChangeMessage(pr),
-                String.format(TOPIC_FORMAT, new Integer(pr.getNumber())));
-        if (changeId != null) {
-          prChanges.add(changeId);
+        if (project.isPresent()) {
+          Id changeId =
+              createChange.addCommitToChange(
+                  project.get(),
+                  gitRepo,
+                  destinationBranch,
+                  pullRequestOwner,
+                  revCommit,
+                  getChangeMessage(pr),
+                  String.format(TOPIC_FORMAT, new Integer(pr.getNumber())));
+          if (changeId != null) {
+            prChanges.add(changeId);
+          }
         }
       }
 
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
index 318dc81..e2b8041 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
@@ -160,9 +160,6 @@
           email,
           fullName,
           username);
-
-      accountCache.evict(accountId);
-      log.debug("Account cache evicted for {}", accountId);
     } catch (Exception e) {
       throw new ServletException(
           "Cannot associate email '" + email + "' to current user '" + user + "'", e);