Fix issue with skipping events from high-availability

ForwarderTask class keeps caller thread object to identify the source
of the event. All events generated by `HTTP POST
/plugins/high-availability/index/change/...` thread are skipped.

The issue is that all threads in HTTP thread pool are named `HTTP-*`
when HTTP call is made thread is renamed to `HTTP POST
/plugins/high-availability/index/change/...`. During the processing
new thread to send the message is created and current HTTP thread is
returned to the pool and it's name is set back to `HTTP-*`.

This means that if the code is not fast enough to check HTTP thread
name before thread is returned to the pool it will get `HTTP-*`
instead of `HTTP POST /plugins/high-availability/index/change/...`
and the event will be forwarded. To avoid this situation keep the
caller thread name instead of thread object.

Bug: Issue 15416
Change-Id: I76f5921793cf844ad638f920127e8f2848a2615e
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwarderTask.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwarderTask.java
index 329b5cb..c5706a5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwarderTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwarderTask.java
@@ -15,9 +15,9 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 public abstract class ForwarderTask implements Runnable {
-  private final Thread callerThread = Thread.currentThread();
+  private final String callerThreadName = Thread.currentThread().getName();
 
-  public Thread getCallerThread() {
-    return callerThread;
+  public String getCallerThreadName() {
+    return callerThreadName;
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java
index 49e6e1e..56167db 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java
@@ -32,7 +32,7 @@
   }
 
   protected boolean currentThreadBelongsToHighAvailabilityPlugin(ForwarderTask task) {
-    String currentThreadName = task.getCallerThread().getName();
+    String currentThreadName = task.getCallerThreadName();
 
     return currentThreadName.contains(HIGH_AVAILABILITY_PLUGIN)
         || currentThreadName.contains(HIGH_AVAILABILITY_FORWARDER)