Fix threads leak when PostTask is executed

Issue:
When PostTask is created it receives executor that is created by
ExecutorProvider. Provider is not scoped therefore new instance is
created each time when new PostTask is created. As a result executors
are being constantly created and never re-used.

Solution:
Bind ExecutorProvider to SINGLETON scope so that it keeps returning the
same executor that is effectively re-used by PostTask instances.

Note: to increase throughput default threadPoolSize was increased to 2.

Change-Id: I6ae0a2cf9f17df529a209735eca30593891194c3
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/Configuration.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/Configuration.java
index 8c4a6c6..68bfa74 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/Configuration.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/Configuration.java
@@ -30,7 +30,7 @@
   private static final int DEFAULT_TIMEOUT_MS = 5000;
   private static final int DEFAULT_MAX_TRIES = 5;
   private static final int DEFAULT_RETRY_INTERVAL = 1000;
-  private static final int DEFAULT_THREAD_POOL_SIZE = 1;
+  private static final int DEFAULT_THREAD_POOL_SIZE = 2;
 
   private final int connectionTimeout;
   private final int socketTimeout;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java
index 10d3e76..f8f5114 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java
@@ -36,7 +36,8 @@
   protected void configure() {
     bind(ScheduledThreadPoolExecutor.class)
         .annotatedWith(WebHooksExecutor.class)
-        .toProvider(ExecutorProvider.class);
+        .toProvider(ExecutorProvider.class)
+        .in(Scopes.SINGLETON);
     bind(Configuration.class).in(Scopes.SINGLETON);
     bind(CloseableHttpClient.class).toProvider(HttpClientProvider.class)
         .in(Scopes.SINGLETON);
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 338a289..88ecdba 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -66,4 +66,4 @@
 
 @PLUGIN@.threadPoolSize
 :   Maximum number of threads used to send events to the target instance.
-    Defaults to 1.
+    Defaults to 2.
\ No newline at end of file