guice optimization
only under debug logging use the source provider to find the line number through stack trace elements, otherwise, its very expensive
This commit is contained in:
parent
b9a2fbd874
commit
f4d1895399
|
@ -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
|
||||
Object ret;
|
||||
if (logger.isDebugEnabled()) {
|
||||
ret = sourceProvider != null
|
||||
? sourceProvider.get()
|
||||
: source;
|
||||
} else {
|
||||
ret = source;
|
||||
}
|
||||
return ret == null ? "_unknown_" : ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue