Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  ChangeUpdatedListener: Extract PluginConfig to a local variable
  Remove unneeded finals

Change-Id: I4068ea22e4881353eb5244735166cbb1c2fae497
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..6a71881 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ChangeUpdatedListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ChangeUpdatedListener.java
@@ -21,6 +21,7 @@
 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.PluginConfig;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.events.Event;
 import com.google.gerrit.server.events.EventListener;
@@ -61,15 +62,15 @@
 
   @Inject
   ChangeUpdatedListener(
-      final ReviewersByBlame.Factory reviewersByBlameFactory,
-      final GitRepositoryManager repoManager,
-      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) {
+      ReviewersByBlame.Factory reviewersByBlameFactory,
+      GitRepositoryManager repoManager,
+      WorkQueue workQueue,
+      IdentifiedUser.GenericFactory identifiedUserFactory,
+      ThreadLocalRequestContext tl,
+      SchemaFactory<ReviewDb> schemaFactory,
+      PluginConfigFactory cfg,
+      ChangeData.Factory changeDataFactory,
+      @PluginName String pluginName) {
     this.reviewersByBlameFactory = reviewersByBlameFactory;
     this.repoManager = repoManager;
     this.workQueue = workQueue;
@@ -93,15 +94,10 @@
     String ignoreSubjectRegEx;
     String ignoreFileRegEx;
     try {
-      maxReviewers =
-          cfg.getFromProjectConfigWithInheritance(projectName, pluginName)
-              .getInt("maxReviewers", 3);
-      ignoreSubjectRegEx =
-          cfg.getFromProjectConfigWithInheritance(projectName, pluginName)
-              .getString("ignoreSubjectRegEx", "");
-      ignoreFileRegEx =
-          cfg.getFromProjectConfigWithInheritance(projectName, pluginName)
-              .getString("ignoreFileRegEx", "");
+      PluginConfig projectConfig = cfg.getFromProjectConfigWithInheritance(projectName, pluginName);
+      maxReviewers = projectConfig.getInt("maxReviewers", 3);
+      ignoreSubjectRegEx = projectConfig.getString("ignoreSubjectRegEx", "");
+      ignoreFileRegEx = projectConfig.getString("ignoreFileRegEx", "");
     } catch (NoSuchProjectException x) {
       log.error(x.getMessage(), x);
       return;
@@ -114,7 +110,7 @@
         RevWalk rw = new RevWalk(git);
         ReviewDb reviewDb = schemaFactory.open()) {
       Change.Id changeId = new Change.Id(e.change.get().number);
-      final ChangeData cd = changeDataFactory.create(reviewDb, projectName, changeId);
+      ChangeData cd = changeDataFactory.create(reviewDb, projectName, changeId);
       if (cd == null) {
         log.warn(
             "Change with id: '{}' on project key: '{}' not found.",
@@ -122,7 +118,7 @@
             projectName.toString());
         return;
       }
-      final Change change = cd.change();
+      Change change = cd.change();
       PatchSet.Id psId = new PatchSet.Id(changeId, e.patchSet.get().number);
       PatchSet ps = cd.patchSet(psId);
       if (ps == null) {
@@ -130,13 +126,13 @@
         return;
       }
 
-      final RevCommit commit = rw.parseCommit(ObjectId.fromString(e.patchSet.get().revision));
+      RevCommit commit = rw.parseCommit(ObjectId.fromString(e.patchSet.get().revision));
 
       if (!ignoreSubjectRegEx.isEmpty() && commit.getShortMessage().matches(ignoreSubjectRegEx)) {
         return;
       }
 
-      final Runnable task =
+      Runnable task =
           reviewersByBlameFactory.create(commit, change, ps, maxReviewers, git, ignoreFileRegEx);
 
       workQueue
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ReviewersByBlame.java b/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ReviewersByBlame.java
index 7b3b31d..8ca04cb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ReviewersByBlame.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewersbyblame/ReviewersByBlame.java
@@ -81,16 +81,16 @@
 
   @Inject
   public ReviewersByBlame(
-      final Emails emails,
-      final AccountCache accountCache,
-      final PatchListCache patchListCache,
+      Emails emails,
+      AccountCache accountCache,
+      PatchListCache patchListCache,
       GerritApi gApi,
-      @Assisted final RevCommit commit,
-      @Assisted final Change change,
-      @Assisted final PatchSet ps,
-      @Assisted final int maxReviewers,
-      @Assisted final Repository repo,
-      @Assisted final String ignoreFileRegEx) {
+      @Assisted RevCommit commit,
+      @Assisted Change change,
+      @Assisted PatchSet ps,
+      @Assisted int maxReviewers,
+      @Assisted Repository repo,
+      @Assisted String ignoreFileRegEx) {
     this.emails = emails;
     this.accountCache = accountCache;
     this.patchListCache = patchListCache;
@@ -160,7 +160,7 @@
    * @param reviewers A set of reviewers with their weight mapped to their {@link Account}
    * @return Reviewers that are best matches for this change, empty if none, never <code>null</code>
    */
-  private Set<Account.Id> findTopReviewers(final Map<Account, Integer> reviewers) {
+  private Set<Account.Id> findTopReviewers(Map<Account, Integer> reviewers) {
     Set<Account.Id> topReviewers = Sets.newHashSet();
     List<Entry<Account, Integer>> entries =
         Ordering.from(
@@ -185,8 +185,7 @@
    * @param blameResult Result of blame computation
    * @return a set of all possible reviewers, empty if none, never <code>null</code>
    */
-  private Map<Account, Integer> getReviewersForPatch(
-      final List<Edit> edits, final BlameResult blameResult) {
+  private Map<Account, Integer> getReviewersForPatch(List<Edit> edits, BlameResult blameResult) {
     Map<Account, Integer> reviewers = Maps.newHashMap();
     for (Edit edit : edits) {
       for (int i = edit.getBeginA(); i < edit.getEndA(); i++) {
@@ -220,7 +219,7 @@
    * @param parent Parent {@link RevCommit}
    * @return Result of blame computation, null if the computation fails
    */
-  private BlameResult computeBlame(final PatchListEntry entry, final RevCommit parent) {
+  private BlameResult computeBlame(PatchListEntry entry, RevCommit parent) {
     BlameCommand blameCommand = new BlameCommand(repo);
     blameCommand.setStartCommit(parent);
     blameCommand.setFilePath(entry.getNewName());