From ec4307f080599e0f299fa653fde75cf05c8291da Mon Sep 17 00:00:00 2001 From: jaymode Date: Wed, 21 Oct 2015 15:01:24 -0400 Subject: [PATCH] properly bind ClassSet extensions as singletons The ExtensionPoint.ClassSet binds adds the extension classes to a a Multibinder and binds the classes and calls the asEagerSingleton method on the multibinder. This does not actually create a singleton. Instead we first bind the class as a singleton and add then add the class to the multibinder. Closes #14194 --- .../java/org/elasticsearch/common/util/ExtensionPoint.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java b/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java index 056142a48c7..2ce4190a00e 100644 --- a/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java +++ b/core/src/main/java/org/elasticsearch/common/util/ExtensionPoint.java @@ -191,7 +191,8 @@ public abstract class ExtensionPoint { protected final void bindExtensions(Binder binder) { Multibinder allocationMultibinder = Multibinder.newSetBinder(binder, extensionClass); for (Class clazz : extensions) { - allocationMultibinder.addBinding().to(clazz).asEagerSingleton(); + binder.bind(clazz).asEagerSingleton(); + allocationMultibinder.addBinding().to(clazz); } } }