Bind Gson.class as Singleton in EventBroker

Gerrit has an internal bus (EventBroker) responsible
for formatting and sending events to the other subsystems,
including e-mail notifications, stream events, and other plugins.

For every event, a Gson object was injected through the use
of EventGsonProvider, which was then creating custom serializer
and deserializers.

With a simple 10 minutes load generated by 10 users, Gerrit was
creating a staggering 25k Gson objects and associated serializers.

There is no reason for not reusing Gson across events, as the
class instances are fully thread-safe [1].

[1] https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.0/com/google/gson/Gson.html

Release-Notes: Reduce memory pressure on the JVM GC by reusing Gson objects across events
Change-Id: Icd156855906166dd5805e3841d5a7420ed5a7bed
diff --git a/java/com/google/gerrit/server/events/EventBroker.java b/java/com/google/gerrit/server/events/EventBroker.java
index 2697da5..71256bd 100644
--- a/java/com/google/gerrit/server/events/EventBroker.java
+++ b/java/com/google/gerrit/server/events/EventBroker.java
@@ -52,7 +52,10 @@
       DynamicItem.itemOf(binder(), EventDispatcher.class);
       DynamicItem.bind(binder(), EventDispatcher.class).to(EventBroker.class);
 
-      bind(Gson.class).annotatedWith(EventGson.class).toProvider(EventGsonProvider.class);
+      bind(Gson.class)
+          .annotatedWith(EventGson.class)
+          .toProvider(EventGsonProvider.class)
+          .in(Singleton.class);
     }
   }