diff --git a/src/main/java/org/elasticsearch/common/inject/spi/Elements.java b/src/main/java/org/elasticsearch/common/inject/spi/Elements.java index 9d4eed47b38..d9b9c06e482 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/Elements.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/Elements.java @@ -19,12 +19,15 @@ package org.elasticsearch.common.inject.spi; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import org.elasticsearch.bootstrap.Bootstrap; import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.binder.AnnotatedBindingBuilder; import org.elasticsearch.common.inject.binder.AnnotatedConstantBindingBuilder; import org.elasticsearch.common.inject.binder.AnnotatedElementBuilder; import org.elasticsearch.common.inject.internal.*; import org.elasticsearch.common.inject.matcher.Matcher; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.Loggers; import java.lang.annotation.Annotation; import java.util.*; @@ -309,10 +312,18 @@ public final class Elements { return builder; } + private static ESLogger logger = Loggers.getLogger(Bootstrap.class); + protected Object getSource() { - return sourceProvider != null - ? sourceProvider.get() - : source; + Object ret; + if (logger.isDebugEnabled()) { + ret = sourceProvider != null + ? sourceProvider.get() + : source; + } else { + ret = source; + } + return ret == null ? "_unknown_" : ret; } @Override