Adapt to removal of ReviewDb

Bug: Issue 10331
Change-Id: If1100152ae4c6969bb665b71cc9adb15622805d7
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ChangeUpdatedListener.java b/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ChangeUpdatedListener.java
index 95b5cb8..be16964 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ChangeUpdatedListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ChangeUpdatedListener.java
@@ -18,7 +18,6 @@
 import com.google.gerrit.reviewdb.client.Change;
 import com.google.gerrit.reviewdb.client.PatchSet;
 import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.server.ReviewDb;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.config.PluginConfigFactory;
@@ -32,10 +31,7 @@
 import com.google.gerrit.server.util.RequestContext;
 import com.google.gerrit.server.util.ThreadLocalRequestContext;
 import com.google.gwtorm.server.OrmException;
-import com.google.gwtorm.server.SchemaFactory;
 import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.ProvisionException;
 import java.io.IOException;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.Repository;
@@ -53,11 +49,9 @@
   private final WorkQueue workQueue;
   private final IdentifiedUser.GenericFactory identifiedUserFactory;
   private final ThreadLocalRequestContext tl;
-  private final SchemaFactory<ReviewDb> schemaFactory;
   private final PluginConfigFactory cfg;
   private final String pluginName;
   private final ChangeData.Factory changeDataFactory;
-  private ReviewDb db;
 
   @Inject
   ChangeUpdatedListener(
@@ -66,7 +60,6 @@
       final WorkQueue workQueue,
       final IdentifiedUser.GenericFactory identifiedUserFactory,
       final ThreadLocalRequestContext tl,
-      final SchemaFactory<ReviewDb> schemaFactory,
       final PluginConfigFactory cfg,
       final ChangeData.Factory changeDataFactory,
       final @PluginName String pluginName) {
@@ -75,7 +68,6 @@
     this.workQueue = workQueue;
     this.identifiedUserFactory = identifiedUserFactory;
     this.tl = tl;
-    this.schemaFactory = schemaFactory;
     this.cfg = cfg;
     this.changeDataFactory = changeDataFactory;
     this.pluginName = pluginName;
@@ -111,10 +103,9 @@
     }
 
     try (Repository git = repoManager.openRepository(projectName);
-        RevWalk rw = new RevWalk(git);
-        ReviewDb reviewDb = schemaFactory.open()) {
+        RevWalk rw = new RevWalk(git)) {
       Change.Id changeId = new Change.Id(e.change.get().number);
-      final ChangeData cd = changeDataFactory.create(reviewDb, projectName, changeId);
+      final ChangeData cd = changeDataFactory.create(projectName, changeId);
       if (cd == null) {
         log.warn(
             "Change with id: '{}' on project key: '{}' not found.",
@@ -153,32 +144,11 @@
                             public CurrentUser getUser() {
                               return identifiedUserFactory.create(change.getOwner());
                             }
-
-                            @Override
-                            public Provider<ReviewDb> getReviewDbProvider() {
-                              return new Provider<ReviewDb>() {
-                                @Override
-                                public ReviewDb get() {
-                                  if (db == null) {
-                                    try {
-                                      db = schemaFactory.open();
-                                    } catch (OrmException e) {
-                                      throw new ProvisionException("Cannot open ReviewDb", e);
-                                    }
-                                  }
-                                  return db;
-                                }
-                              };
-                            }
                           });
                   try {
                     task.run();
                   } finally {
                     tl.setContext(old);
-                    if (db != null) {
-                      db.close();
-                      db = null;
-                    }
                   }
                 }
               });