Merge branch 'stable-2.14' into 'stable-2.15'

* google/stable-2.14:
  Name the publisher thread
  Do not block Gerrit's event bus when queue is full
  Clean up the Publisher interface and implementations
  Format Java files with google-java-format
  Serialize Project.NameKey correctly

Change-Id: Ie9f94aaf1e3e5c831c305d0cfce85ce61ed00a4e
diff --git a/README.md b/README.md
index b3b6665..86a28a5 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,8 @@
 Synopsis
 ----------------------
 
-This is Gerrit plugin.
-
-This can publish gerrit events to message queue provided by RabbitMQ.
-Published events are the same as Gerrit stream evnets.
-
-This plugin works on Gerrit 2.8 - 2.13.
+Publish gerrit stream events to a RabbitMQ queue.
+This plugin works with any version of Gerrit starting from v2.8.
 
 Environments
 ---------------------
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index 70ed9e6..0af44ef 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -3,6 +3,6 @@
 def external_plugin_deps():
     maven_jar(
         name = "amqp_client",
-        artifact = "com.rabbitmq:amqp-client:3.5.2",
-        sha1 = "8d10edd29e08f78349bd1da9d18f81c9f8b90567",
+        artifact = "com.rabbitmq:amqp-client:4.1.1",
+        sha1 = "256f6c92c55a8d3cfae8d32e1a15713baedab184",
     )
diff --git a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSession.java b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSession.java
index 25ec9f9..6284b86 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSession.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSession.java
@@ -161,8 +161,7 @@
       }
     } catch (URISyntaxException ex) {
       LOGGER.error(MSG("URI syntax error: {}"), amqp.uri);
-
-    } catch (IOException ex) {
+    } catch (IOException | TimeoutException ex) {
       LOGGER.error(MSG("Connection cannot be opened."), ex);
     } catch (KeyManagementException | NoSuchAlgorithmException ex) {
       LOGGER.error(MSG("Security error when opening connection."), ex);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/worker/UserEventWorker.java b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/worker/UserEventWorker.java
index 324215d..126a8b7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/worker/UserEventWorker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/worker/UserEventWorker.java
@@ -33,8 +33,10 @@
 import com.google.inject.Provider;
 import com.google.inject.ProvisionException;
 import com.googlesource.gerrit.plugins.rabbitmq.message.Publisher;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -113,7 +115,7 @@
                           }
                         });
                 try {
-                  userAccount = accountResolver.find(db, userName);
+                  userAccount = accountResolver.find(userName);
                   if (userAccount == null) {
                     LOGGER.error(
                         "No single user could be found when searching for listenAs: {}", userName);
@@ -135,7 +137,7 @@
                           });
                   eventListenerRegistrations.put(publisher, registration);
                   LOGGER.info("Listen events as : {}", userName);
-                } catch (OrmException e) {
+                } catch (OrmException | ConfigInvalidException | IOException e) {
                   LOGGER.error("Could not query database for listenAs", e);
                   return;
                 } finally {