Merge branch 'master' into 1702090

This commit is contained in:
Robert Muir 2015-09-10 21:41:07 -04:00
commit dd208002c9
39 changed files with 161 additions and 166 deletions

View File

@ -19,12 +19,13 @@
package org.elasticsearch.action; package org.elasticsearch.action;
import com.google.common.base.Preconditions;
import org.elasticsearch.action.support.PlainListenableActionFuture; import org.elasticsearch.action.support.PlainListenableActionFuture;
import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import java.util.Objects;
/** /**
* *
*/ */
@ -36,7 +37,7 @@ public abstract class ActionRequestBuilder<Request extends ActionRequest, Respon
protected final ElasticsearchClient client; protected final ElasticsearchClient client;
protected ActionRequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action, Request request) { protected ActionRequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action, Request request) {
Preconditions.checkNotNull(action, "action must not be null"); Objects.requireNonNull(action, "action must not be null");
this.action = action; this.action = action;
this.request = request; this.request = request;
this.client = client; this.client = client;

View File

@ -25,8 +25,8 @@ import org.elasticsearch.common.inject.spi.TypeConverter;
import org.elasticsearch.common.inject.spi.TypeListener; import org.elasticsearch.common.inject.spi.TypeListener;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
/** /**
@ -56,7 +56,7 @@ public abstract class AbstractModule implements Module {
public final synchronized void configure(Binder builder) { public final synchronized void configure(Binder builder) {
checkState(this.binder == null, "Re-entry is not allowed."); checkState(this.binder == null, "Re-entry is not allowed.");
this.binder = checkNotNull(builder, "builder"); this.binder = Objects.requireNonNull(builder, "builder");
try { try {
configure(); configure();
} finally { } finally {

View File

@ -33,8 +33,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* @author jessewilson@google.com (Jesse Wilson) * @author jessewilson@google.com (Jesse Wilson)
@ -54,7 +53,7 @@ class InheritingState implements State {
private final Object lock; private final Object lock;
InheritingState(State parent) { InheritingState(State parent) {
this.parent = checkNotNull(parent, "parent"); this.parent = Objects.requireNonNull(parent, "parent");
this.lock = (parent == State.NONE) ? this : parent.lock(); this.lock = (parent == State.NONE) ? this : parent.lock();
} }

View File

@ -23,11 +23,10 @@ import org.elasticsearch.common.inject.spi.InjectionPoint;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Manages and injects instances at injector-creation time. This is made more complicated by * Manages and injects instances at injector-creation time. This is made more complicated by
* instances that request other instances while they're being injected. We overcome this by using * instances that request other instances while they're being injected. We overcome this by using
@ -60,7 +59,7 @@ class Initializer {
*/ */
public <T> Initializable<T> requestInjection(InjectorImpl injector, T instance, Object source, public <T> Initializable<T> requestInjection(InjectorImpl injector, T instance, Object source,
Set<InjectionPoint> injectionPoints) { Set<InjectionPoint> injectionPoints) {
checkNotNull(source); Objects.requireNonNull(source);
// short circuit if the object has no injections // short circuit if the object has no injections
if (instance == null if (instance == null
@ -118,8 +117,8 @@ class Initializer {
public InjectableReference(InjectorImpl injector, T instance, Object source) { public InjectableReference(InjectorImpl injector, T instance, Object source) {
this.injector = injector; this.injector = injector;
this.instance = checkNotNull(instance, "instance"); this.instance = Objects.requireNonNull(instance, "instance");
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
} }
public void validate(Errors errors) throws ErrorsException { public void validate(Errors errors) throws ErrorsException {

View File

@ -35,9 +35,9 @@ import org.elasticsearch.common.inject.spi.TypeListenerBinding;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.logging.Logger; import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static org.elasticsearch.common.inject.Scopes.SINGLETON; import static org.elasticsearch.common.inject.Scopes.SINGLETON;
@ -257,7 +257,7 @@ class InjectorShell {
final Stage stage; final Stage stage;
private RootModule(Stage stage) { private RootModule(Stage stage) {
this.stage = checkNotNull(stage, "stage"); this.stage = Objects.requireNonNull(stage, "stage");
} }
@Override @Override

View File

@ -19,7 +19,7 @@ package org.elasticsearch.common.inject;
import org.elasticsearch.common.inject.internal.*; import org.elasticsearch.common.inject.internal.*;
import org.elasticsearch.common.inject.spi.Dependency; import org.elasticsearch.common.inject.spi.Dependency;
import static com.google.common.base.Preconditions.checkNotNull; import java.util.Objects;
/** /**
* @author crazybob@google.com (Bob Lee) * @author crazybob@google.com (Bob Lee)
@ -35,8 +35,8 @@ class InternalFactoryToProviderAdapter<T> implements InternalFactory<T> {
public InternalFactoryToProviderAdapter( public InternalFactoryToProviderAdapter(
Initializable<Provider<? extends T>> initializable, Object source) { Initializable<Provider<? extends T>> initializable, Object source) {
this.initializable = checkNotNull(initializable, "provider"); this.initializable = Objects.requireNonNull(initializable, "provider");
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
} }
@Override @Override

View File

@ -22,9 +22,9 @@ import org.elasticsearch.common.inject.internal.ToStringBuilder;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Binding key consisting of an injection type and an optional annotation. * Binding key consisting of an injection type and an optional annotation.
@ -343,7 +343,7 @@ public class Key<T> {
* Gets the strategy for an annotation. * Gets the strategy for an annotation.
*/ */
static AnnotationStrategy strategyFor(Annotation annotation) { static AnnotationStrategy strategyFor(Annotation annotation) {
checkNotNull(annotation, "annotation"); Objects.requireNonNull(annotation, "annotation");
Class<? extends Annotation> annotationType = annotation.annotationType(); Class<? extends Annotation> annotationType = annotation.annotationType();
ensureRetainedAtRuntime(annotationType); ensureRetainedAtRuntime(annotationType);
ensureIsBindingAnnotation(annotationType); ensureIsBindingAnnotation(annotationType);
@ -359,7 +359,7 @@ public class Key<T> {
* Gets the strategy for an annotation type. * Gets the strategy for an annotation type.
*/ */
static AnnotationStrategy strategyFor(Class<? extends Annotation> annotationType) { static AnnotationStrategy strategyFor(Class<? extends Annotation> annotationType) {
checkNotNull(annotationType, "annotation type"); Objects.requireNonNull(annotationType, "annotation type");
ensureRetainedAtRuntime(annotationType); ensureRetainedAtRuntime(annotationType);
ensureIsBindingAnnotation(annotationType); ensureIsBindingAnnotation(annotationType);
return new AnnotationTypeStrategy(annotationType, null); return new AnnotationTypeStrategy(annotationType, null);
@ -414,7 +414,7 @@ public class Key<T> {
final Annotation annotation; final Annotation annotation;
AnnotationInstanceStrategy(Annotation annotation) { AnnotationInstanceStrategy(Annotation annotation) {
this.annotation = checkNotNull(annotation, "annotation"); this.annotation = Objects.requireNonNull(annotation, "annotation");
} }
@Override @Override
@ -467,7 +467,7 @@ public class Key<T> {
AnnotationTypeStrategy(Class<? extends Annotation> annotationType, AnnotationTypeStrategy(Class<? extends Annotation> annotationType,
Annotation annotation) { Annotation annotation) {
this.annotationType = checkNotNull(annotationType, "annotation type"); this.annotationType = Objects.requireNonNull(annotationType, "annotation type");
this.annotation = annotation; this.annotation = annotation;
} }

View File

@ -21,8 +21,7 @@ import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.spi.ScopeBinding; import org.elasticsearch.common.inject.spi.ScopeBinding;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Handles {@link Binder#bindScope} commands. * Handles {@link Binder#bindScope} commands.
@ -52,11 +51,11 @@ class ScopeBindingProcessor extends AbstractProcessor {
// Go ahead and bind anyway so we don't get collateral errors. // Go ahead and bind anyway so we don't get collateral errors.
} }
Scope existing = injector.state.getScope(checkNotNull(annotationType, "annotation type")); Scope existing = injector.state.getScope(Objects.requireNonNull(annotationType, "annotation type"));
if (existing != null) { if (existing != null) {
errors.duplicateScopes(existing, annotationType, scope); errors.duplicateScopes(existing, annotationType, scope);
} else { } else {
injector.state.putAnnotation(annotationType, checkNotNull(scope, "scope")); injector.state.putAnnotation(annotationType, Objects.requireNonNull(scope, "scope"));
} }
return true; return true;

View File

@ -21,11 +21,10 @@ import org.elasticsearch.common.inject.util.Types;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.elasticsearch.common.inject.internal.MoreTypes.canonicalize; import static org.elasticsearch.common.inject.internal.MoreTypes.canonicalize;
/** /**
@ -85,7 +84,7 @@ public class TypeLiteral<T> {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
TypeLiteral(Type type) { TypeLiteral(Type type) {
this.type = canonicalize(checkNotNull(type, "type")); this.type = canonicalize(Objects.requireNonNull(type, "type"));
this.rawType = (Class<? super T>) MoreTypes.getRawType(this.type); this.rawType = (Class<? super T>) MoreTypes.getRawType(this.type);
this.hashCode = MoreTypes.hashCode(this.type); this.hashCode = MoreTypes.hashCode(this.type);
} }

View File

@ -24,8 +24,7 @@ import org.elasticsearch.common.inject.spi.InstanceBinding;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.List; import java.util.List;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Bind a value or constant. * Bind a value or constant.
@ -73,7 +72,7 @@ public abstract class AbstractBindingBuilder<T> {
* Sets the binding to a copy with the specified annotation on the bound key * Sets the binding to a copy with the specified annotation on the bound key
*/ */
protected BindingImpl<T> annotatedWithInternal(Class<? extends Annotation> annotationType) { protected BindingImpl<T> annotatedWithInternal(Class<? extends Annotation> annotationType) {
checkNotNull(annotationType, "annotationType"); Objects.requireNonNull(annotationType, "annotationType");
checkNotAnnotated(); checkNotAnnotated();
return setBinding(binding.withKey( return setBinding(binding.withKey(
Key.get(this.binding.getKey().getTypeLiteral(), annotationType))); Key.get(this.binding.getKey().getTypeLiteral(), annotationType)));
@ -83,20 +82,20 @@ public abstract class AbstractBindingBuilder<T> {
* Sets the binding to a copy with the specified annotation on the bound key * Sets the binding to a copy with the specified annotation on the bound key
*/ */
protected BindingImpl<T> annotatedWithInternal(Annotation annotation) { protected BindingImpl<T> annotatedWithInternal(Annotation annotation) {
checkNotNull(annotation, "annotation"); Objects.requireNonNull(annotation, "annotation");
checkNotAnnotated(); checkNotAnnotated();
return setBinding(binding.withKey( return setBinding(binding.withKey(
Key.get(this.binding.getKey().getTypeLiteral(), annotation))); Key.get(this.binding.getKey().getTypeLiteral(), annotation)));
} }
public void in(final Class<? extends Annotation> scopeAnnotation) { public void in(final Class<? extends Annotation> scopeAnnotation) {
checkNotNull(scopeAnnotation, "scopeAnnotation"); Objects.requireNonNull(scopeAnnotation, "scopeAnnotation");
checkNotScoped(); checkNotScoped();
setBinding(getBinding().withScoping(Scoping.forAnnotation(scopeAnnotation))); setBinding(getBinding().withScoping(Scoping.forAnnotation(scopeAnnotation)));
} }
public void in(final Scope scope) { public void in(final Scope scope) {
checkNotNull(scope, "scope"); Objects.requireNonNull(scope, "scope");
checkNotScoped(); checkNotScoped();
setBinding(getBinding().withScoping(Scoping.forInstance(scope))); setBinding(getBinding().withScoping(Scoping.forInstance(scope)));
} }

View File

@ -25,10 +25,9 @@ import org.elasticsearch.common.inject.spi.Message;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Bind a non-constant key. * Bind a non-constant key.
* *
@ -65,7 +64,7 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
@Override @Override
public BindingBuilder<T> to(Key<? extends T> linkedKey) { public BindingBuilder<T> to(Key<? extends T> linkedKey) {
checkNotNull(linkedKey, "linkedKey"); Objects.requireNonNull(linkedKey, "linkedKey");
checkNotTargetted(); checkNotTargetted();
BindingImpl<T> base = getBinding(); BindingImpl<T> base = getBinding();
setBinding(new LinkedBindingImpl<>( setBinding(new LinkedBindingImpl<>(
@ -100,7 +99,7 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
@Override @Override
public BindingBuilder<T> toProvider(Provider<? extends T> provider) { public BindingBuilder<T> toProvider(Provider<? extends T> provider) {
checkNotNull(provider, "provider"); Objects.requireNonNull(provider, "provider");
checkNotTargetted(); checkNotTargetted();
// lookup the injection points, adding any errors to the binder's errors list // lookup the injection points, adding any errors to the binder's errors list
@ -127,7 +126,7 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
@Override @Override
public BindingBuilder<T> toProvider(Key<? extends Provider<? extends T>> providerKey) { public BindingBuilder<T> toProvider(Key<? extends Provider<? extends T>> providerKey) {
checkNotNull(providerKey, "providerKey"); Objects.requireNonNull(providerKey, "providerKey");
checkNotTargetted(); checkNotTargetted();
BindingImpl<T> base = getBinding(); BindingImpl<T> base = getBinding();

View File

@ -21,6 +21,7 @@ import org.elasticsearch.common.inject.Key;
import org.elasticsearch.common.inject.binder.AnnotatedElementBuilder; import org.elasticsearch.common.inject.binder.AnnotatedElementBuilder;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.Objects;
/** /**
* For private binder's expose() method. * For private binder's expose() method.
@ -44,14 +45,14 @@ public class ExposureBuilder<T> implements AnnotatedElementBuilder {
@Override @Override
public void annotatedWith(Class<? extends Annotation> annotationType) { public void annotatedWith(Class<? extends Annotation> annotationType) {
com.google.common.base.Preconditions.checkNotNull(annotationType, "annotationType"); Objects.requireNonNull(annotationType, "annotationType");
checkNotAnnotated(); checkNotAnnotated();
key = Key.get(key.getTypeLiteral(), annotationType); key = Key.get(key.getTypeLiteral(), annotationType);
} }
@Override @Override
public void annotatedWith(Annotation annotation) { public void annotatedWith(Annotation annotation) {
com.google.common.base.Preconditions.checkNotNull(annotation, "annotation"); Objects.requireNonNull(annotation, "annotation");
checkNotAnnotated(); checkNotAnnotated();
key = Key.get(key.getTypeLiteral(), annotation); key = Key.get(key.getTypeLiteral(), annotation);
} }

View File

@ -22,8 +22,7 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Utility for joining pieces of text separated by a delimiter. It can handle * Utility for joining pieces of text separated by a delimiter. It can handle
@ -97,7 +96,7 @@ public final class Join {
*/ */
public static String join( public static String join(
String delimiter, @Nullable Object firstToken, Object... otherTokens) { String delimiter, @Nullable Object firstToken, Object... otherTokens) {
checkNotNull(otherTokens); Objects.requireNonNull(otherTokens);
return join(delimiter, CollectionUtils.asArrayList(firstToken, otherTokens)); return join(delimiter, CollectionUtils.asArrayList(firstToken, otherTokens));
} }
@ -207,7 +206,7 @@ public final class Join {
*/ */
public static <T extends Appendable> T join(T appendable, String delimiter, public static <T extends Appendable> T join(T appendable, String delimiter,
@Nullable Object firstToken, Object... otherTokens) { @Nullable Object firstToken, Object... otherTokens) {
checkNotNull(otherTokens); Objects.requireNonNull(otherTokens);
return join(appendable, delimiter, CollectionUtils.asArrayList(firstToken, otherTokens)); return join(appendable, delimiter, CollectionUtils.asArrayList(firstToken, otherTokens));
} }
@ -232,8 +231,8 @@ public final class Join {
/* This method is the workhorse of the class */ /* This method is the workhorse of the class */
checkNotNull(appendable); Objects.requireNonNull(appendable);
checkNotNull(delimiter); Objects.requireNonNull(delimiter);
if (tokens.hasNext()) { if (tokens.hasNext()) {
try { try {
appendOneToken(appendable, tokens.next()); appendOneToken(appendable, tokens.next());
@ -268,9 +267,9 @@ public final class Join {
*/ */
public static <T extends Appendable> T join(T appendable, public static <T extends Appendable> T join(T appendable,
String keyValueSeparator, String entryDelimiter, Map<?, ?> map) { String keyValueSeparator, String entryDelimiter, Map<?, ?> map) {
checkNotNull(appendable); Objects.requireNonNull(appendable);
checkNotNull(keyValueSeparator); Objects.requireNonNull(keyValueSeparator);
checkNotNull(entryDelimiter); Objects.requireNonNull(entryDelimiter);
Iterator<? extends Map.Entry<?, ?>> entries = map.entrySet().iterator(); Iterator<? extends Map.Entry<?, ?>> entries = map.entrySet().iterator();
if (entries.hasNext()) { if (entries.hasNext()) {
try { try {

View File

@ -20,7 +20,7 @@ import org.elasticsearch.common.inject.TypeLiteral;
import org.elasticsearch.common.inject.matcher.Matcher; import org.elasticsearch.common.inject.matcher.Matcher;
import org.elasticsearch.common.inject.spi.TypeConverter; import org.elasticsearch.common.inject.spi.TypeConverter;
import static com.google.common.base.Preconditions.checkNotNull; import java.util.Objects;
/** /**
* @author crazybob@google.com (Bob Lee) * @author crazybob@google.com (Bob Lee)
@ -33,8 +33,8 @@ public final class MatcherAndConverter {
public MatcherAndConverter(Matcher<? super TypeLiteral<?>> typeMatcher, public MatcherAndConverter(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter typeConverter, Object source) { TypeConverter typeConverter, Object source) {
this.typeMatcher = checkNotNull(typeMatcher, "type matcher"); this.typeMatcher = Objects.requireNonNull(typeMatcher, "type matcher");
this.typeConverter = checkNotNull(typeConverter, "converter"); this.typeConverter = Objects.requireNonNull(typeConverter, "converter");
this.source = source; this.source = source;
} }

View File

@ -31,7 +31,6 @@ import java.util.NoSuchElementException;
import java.util.Objects; import java.util.Objects;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Static methods for working with types that we aren't publishing in the * Static methods for working with types that we aren't publishing in the
@ -316,7 +315,7 @@ public class MoreTypes {
* Returns {@code Field.class}, {@code Method.class} or {@code Constructor.class}. * Returns {@code Field.class}, {@code Method.class} or {@code Constructor.class}.
*/ */
public static Class<? extends Member> memberType(Member member) { public static Class<? extends Member> memberType(Member member) {
checkNotNull(member, "member"); Objects.requireNonNull(member, "member");
if (member instanceof MemberImpl) { if (member instanceof MemberImpl) {
return ((MemberImpl) member).memberType; return ((MemberImpl) member).memberType;
@ -355,7 +354,7 @@ public class MoreTypes {
} }
public static String memberKey(Member member) { public static String memberKey(Member member) {
checkNotNull(member, "member"); Objects.requireNonNull(member, "member");
return "<NO_MEMBER_KEY>"; return "<NO_MEMBER_KEY>";
} }
@ -456,7 +455,7 @@ public class MoreTypes {
this.rawType = canonicalize(rawType); this.rawType = canonicalize(rawType);
this.typeArguments = typeArguments.clone(); this.typeArguments = typeArguments.clone();
for (int t = 0; t < this.typeArguments.length; t++) { for (int t = 0; t < this.typeArguments.length; t++) {
checkNotNull(this.typeArguments[t], "type parameter"); Objects.requireNonNull(this.typeArguments[t], "type parameter");
checkNotPrimitive(this.typeArguments[t], "type parameters"); checkNotPrimitive(this.typeArguments[t], "type parameters");
this.typeArguments[t] = canonicalize(this.typeArguments[t]); this.typeArguments[t] = canonicalize(this.typeArguments[t]);
} }
@ -566,14 +565,14 @@ public class MoreTypes {
checkArgument(upperBounds.length == 1, "Must have exactly one upper bound."); checkArgument(upperBounds.length == 1, "Must have exactly one upper bound.");
if (lowerBounds.length == 1) { if (lowerBounds.length == 1) {
checkNotNull(lowerBounds[0], "lowerBound"); Objects.requireNonNull(lowerBounds[0], "lowerBound");
checkNotPrimitive(lowerBounds[0], "wildcard bounds"); checkNotPrimitive(lowerBounds[0], "wildcard bounds");
checkArgument(upperBounds[0] == Object.class, "bounded both ways"); checkArgument(upperBounds[0] == Object.class, "bounded both ways");
this.lowerBound = canonicalize(lowerBounds[0]); this.lowerBound = canonicalize(lowerBounds[0]);
this.upperBound = Object.class; this.upperBound = Object.class;
} else { } else {
checkNotNull(upperBounds[0], "upperBound"); Objects.requireNonNull(upperBounds[0], "upperBound");
checkNotPrimitive(upperBounds[0], "wildcard bounds"); checkNotPrimitive(upperBounds[0], "wildcard bounds");
this.lowerBound = null; this.lowerBound = null;
this.upperBound = canonicalize(upperBounds[0]); this.upperBound = canonicalize(upperBounds[0]);

View File

@ -30,10 +30,10 @@ import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
/** /**
@ -64,7 +64,7 @@ public final class PrivateElementsImpl implements PrivateElements {
private Injector injector; private Injector injector;
public PrivateElementsImpl(Object source) { public PrivateElementsImpl(Object source) {
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
} }
@Override @Override
@ -89,7 +89,7 @@ public final class PrivateElementsImpl implements PrivateElements {
public void initInjector(Injector injector) { public void initInjector(Injector injector) {
checkState(this.injector == null, "injector already initialized"); checkState(this.injector == null, "injector already initialized");
this.injector = checkNotNull(injector, "injector"); this.injector = Objects.requireNonNull(injector, "injector");
} }
@Override @Override

View File

@ -32,8 +32,7 @@ import java.lang.reflect.Member;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Creates bindings to methods annotated with {@literal @}{@link Provides}. Use the scope and * Creates bindings to methods annotated with {@literal @}{@link Provides}. Use the scope and
@ -47,7 +46,7 @@ public final class ProviderMethodsModule implements Module {
private final TypeLiteral<?> typeLiteral; private final TypeLiteral<?> typeLiteral;
private ProviderMethodsModule(Object delegate) { private ProviderMethodsModule(Object delegate) {
this.delegate = checkNotNull(delegate, "delegate"); this.delegate = Objects.requireNonNull(delegate, "delegate");
this.typeLiteral = TypeLiteral.get(this.delegate.getClass()); this.typeLiteral = TypeLiteral.get(this.delegate.getClass());
} }

View File

@ -22,9 +22,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Matcher implementations. Supports matching classes and methods. * Matcher implementations. Supports matching classes and methods.
@ -73,7 +73,7 @@ public class Matchers {
final Matcher<? super T> delegate; final Matcher<? super T> delegate;
private Not(Matcher<? super T> delegate) { private Not(Matcher<? super T> delegate) {
this.delegate = checkNotNull(delegate, "delegate"); this.delegate = Objects.requireNonNull(delegate, "delegate");
} }
@Override @Override
@ -121,7 +121,7 @@ public class Matchers {
private final Class<? extends Annotation> annotationType; private final Class<? extends Annotation> annotationType;
public AnnotatedWithType(Class<? extends Annotation> annotationType) { public AnnotatedWithType(Class<? extends Annotation> annotationType) {
this.annotationType = checkNotNull(annotationType, "annotation type"); this.annotationType = Objects.requireNonNull(annotationType, "annotation type");
checkForRuntimeRetention(annotationType); checkForRuntimeRetention(annotationType);
} }
@ -163,7 +163,7 @@ public class Matchers {
private final Annotation annotation; private final Annotation annotation;
public AnnotatedWith(Annotation annotation) { public AnnotatedWith(Annotation annotation) {
this.annotation = checkNotNull(annotation, "annotation"); this.annotation = Objects.requireNonNull(annotation, "annotation");
checkForRuntimeRetention(annotation.annotationType()); checkForRuntimeRetention(annotation.annotationType());
} }
@ -205,7 +205,7 @@ public class Matchers {
private final Class<?> superclass; private final Class<?> superclass;
public SubclassesOf(Class<?> superclass) { public SubclassesOf(Class<?> superclass) {
this.superclass = checkNotNull(superclass, "superclass"); this.superclass = Objects.requireNonNull(superclass, "superclass");
} }
@Override @Override
@ -244,7 +244,7 @@ public class Matchers {
private final Object value; private final Object value;
public Only(Object value) { public Only(Object value) {
this.value = checkNotNull(value, "value"); this.value = Objects.requireNonNull(value, "value");
} }
@Override @Override
@ -283,7 +283,7 @@ public class Matchers {
private final Object value; private final Object value;
public IdenticalTo(Object value) { public IdenticalTo(Object value) {
this.value = checkNotNull(value, "value"); this.value = Objects.requireNonNull(value, "value");
} }
@Override @Override
@ -323,7 +323,7 @@ public class Matchers {
private final String packageName; private final String packageName;
public InPackage(Package targetPackage) { public InPackage(Package targetPackage) {
this.targetPackage = checkNotNull(targetPackage, "package"); this.targetPackage = Objects.requireNonNull(targetPackage, "package");
this.packageName = targetPackage.getName(); this.packageName = targetPackage.getName();
} }
@ -410,7 +410,7 @@ public class Matchers {
private final Matcher<? super Class<?>> returnType; private final Matcher<? super Class<?>> returnType;
public Returns(Matcher<? super Class<?>> returnType) { public Returns(Matcher<? super Class<?>> returnType) {
this.returnType = checkNotNull(returnType, "return type matcher"); this.returnType = Objects.requireNonNull(returnType, "return type matcher");
} }
@Override @Override

View File

@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
/** /**
@ -208,10 +209,10 @@ public abstract class Multibinder<T> {
private RealMultibinder(Binder binder, TypeLiteral<T> elementType, private RealMultibinder(Binder binder, TypeLiteral<T> elementType,
String setName, Key<Set<T>> setKey) { String setName, Key<Set<T>> setKey) {
this.binder = checkNotNull(binder, "binder"); this.binder = Objects.requireNonNull(binder, "binder");
this.elementType = checkNotNull(elementType, "elementType"); this.elementType = Objects.requireNonNull(elementType, "elementType");
this.setName = checkNotNull(setName, "setName"); this.setName = Objects.requireNonNull(setName, "setName");
this.setKey = checkNotNull(setKey, "setKey"); this.setKey = Objects.requireNonNull(setKey, "setKey");
} }
@Override @Override

View File

@ -18,15 +18,14 @@ package org.elasticsearch.common.inject.name;
import java.io.Serializable; import java.io.Serializable;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
class NamedImpl implements Named, Serializable { class NamedImpl implements Named, Serializable {
private final String value; private final String value;
public NamedImpl(String value) { public NamedImpl(String value) {
this.value = checkNotNull(value, "name"); this.value = Objects.requireNonNull(value, "name");
} }
@Override @Override

View File

@ -20,10 +20,9 @@ import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.ConfigurationException; import org.elasticsearch.common.inject.ConfigurationException;
import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.TypeLiteral;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* A request to inject the instance fields and methods of an instance. Requests are created * A request to inject the instance fields and methods of an instance. Requests are created
* explicitly in a module using {@link org.elasticsearch.common.inject.Binder#requestInjection(Object) * explicitly in a module using {@link org.elasticsearch.common.inject.Binder#requestInjection(Object)
@ -41,9 +40,9 @@ public final class InjectionRequest<T> implements Element {
private final T instance; private final T instance;
public InjectionRequest(Object source, TypeLiteral<T> type, T instance) { public InjectionRequest(Object source, TypeLiteral<T> type, T instance) {
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
this.type = checkNotNull(type, "type"); this.type = Objects.requireNonNull(type, "type");
this.instance = checkNotNull(instance, "instance"); this.instance = Objects.requireNonNull(instance, "instance");
} }
@Override @Override

View File

@ -20,7 +20,8 @@ import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.MembersInjector; import org.elasticsearch.common.inject.MembersInjector;
import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.TypeLiteral;
import static com.google.common.base.Preconditions.checkNotNull; import java.util.Objects;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
/** /**
@ -40,8 +41,8 @@ public final class MembersInjectorLookup<T> implements Element {
private MembersInjector<T> delegate; private MembersInjector<T> delegate;
public MembersInjectorLookup(Object source, TypeLiteral<T> type) { public MembersInjectorLookup(Object source, TypeLiteral<T> type) {
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
this.type = checkNotNull(type, "type"); this.type = Objects.requireNonNull(type, "type");
} }
@Override @Override
@ -68,7 +69,7 @@ public final class MembersInjectorLookup<T> implements Element {
*/ */
public void initializeDelegate(MembersInjector<T> delegate) { public void initializeDelegate(MembersInjector<T> delegate) {
checkState(this.delegate == null, "delegate already initialized"); checkState(this.delegate == null, "delegate already initialized");
this.delegate = checkNotNull(delegate, "delegate"); this.delegate = Objects.requireNonNull(delegate, "delegate");
} }
@Override @Override

View File

@ -27,8 +27,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* An error message and the context in which it occurred. Messages are usually created internally by * An error message and the context in which it occurred. Messages are usually created internally by
* Guice and its extensions. Messages can be created explicitly in a module using {@link * Guice and its extensions. Messages can be created explicitly in a module using {@link
@ -52,7 +50,7 @@ public final class Message implements Serializable, Element {
*/ */
public Message(List<Object> sources, String message, Throwable cause) { public Message(List<Object> sources, String message, Throwable cause) {
this.sources = Collections.unmodifiableList(sources); this.sources = Collections.unmodifiableList(sources);
this.message = checkNotNull(message, "message"); this.message = Objects.requireNonNull(message, "message");
this.cause = cause; this.cause = cause;
} }

View File

@ -20,7 +20,8 @@ import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.Key;
import org.elasticsearch.common.inject.Provider; import org.elasticsearch.common.inject.Provider;
import static com.google.common.base.Preconditions.checkNotNull; import java.util.Objects;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
/** /**
@ -64,8 +65,8 @@ public final class ProviderLookup<T> implements Element {
private Provider<T> delegate; private Provider<T> delegate;
public ProviderLookup(Object source, Key<T> key) { public ProviderLookup(Object source, Key<T> key) {
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
this.key = checkNotNull(key, "key"); this.key = Objects.requireNonNull(key, "key");
} }
@Override @Override
@ -89,7 +90,7 @@ public final class ProviderLookup<T> implements Element {
*/ */
public void initializeDelegate(Provider<T> delegate) { public void initializeDelegate(Provider<T> delegate) {
checkState(this.delegate == null, "delegate already initialized"); checkState(this.delegate == null, "delegate already initialized");
this.delegate = checkNotNull(delegate, "delegate"); this.delegate = Objects.requireNonNull(delegate, "delegate");
} }
@Override @Override

View File

@ -20,8 +20,7 @@ import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.Scope; import org.elasticsearch.common.inject.Scope;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Registration of a scope annotation with the scope that implements it. Instances are created * Registration of a scope annotation with the scope that implements it. Instances are created
@ -40,9 +39,9 @@ public final class ScopeBinding implements Element {
private final Scope scope; private final Scope scope;
ScopeBinding(Object source, Class<? extends Annotation> annotationType, Scope scope) { ScopeBinding(Object source, Class<? extends Annotation> annotationType, Scope scope) {
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
this.annotationType = checkNotNull(annotationType, "annotationType"); this.annotationType = Objects.requireNonNull(annotationType, "annotationType");
this.scope = checkNotNull(scope, "scope"); this.scope = Objects.requireNonNull(scope, "scope");
} }
@Override @Override

View File

@ -19,10 +19,9 @@ package org.elasticsearch.common.inject.spi;
import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.ConfigurationException; import org.elasticsearch.common.inject.ConfigurationException;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* A request to inject the static fields and methods of a type. Requests are created * A request to inject the static fields and methods of a type. Requests are created
* explicitly in a module using {@link org.elasticsearch.common.inject.Binder#requestStaticInjection(Class[]) * explicitly in a module using {@link org.elasticsearch.common.inject.Binder#requestStaticInjection(Class[])
@ -38,8 +37,8 @@ public final class StaticInjectionRequest implements Element {
private final Class<?> type; private final Class<?> type;
StaticInjectionRequest(Object source, Class<?> type) { StaticInjectionRequest(Object source, Class<?> type) {
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
this.type = checkNotNull(type, "type"); this.type = Objects.requireNonNull(type, "type");
} }
@Override @Override

View File

@ -20,7 +20,7 @@ import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.TypeLiteral;
import org.elasticsearch.common.inject.matcher.Matcher; import org.elasticsearch.common.inject.matcher.Matcher;
import static com.google.common.base.Preconditions.checkNotNull; import java.util.Objects;
/** /**
* Registration of type converters for matching target types. Instances are created * Registration of type converters for matching target types. Instances are created
@ -39,9 +39,9 @@ public final class TypeConverterBinding implements Element {
TypeConverterBinding(Object source, Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverterBinding(Object source, Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter typeConverter) { TypeConverter typeConverter) {
this.source = checkNotNull(source, "source"); this.source = Objects.requireNonNull(source, "source");
this.typeMatcher = checkNotNull(typeMatcher, "typeMatcher"); this.typeMatcher = Objects.requireNonNull(typeMatcher, "typeMatcher");
this.typeConverter = checkNotNull(typeConverter, "typeConverter"); this.typeConverter = Objects.requireNonNull(typeConverter, "typeConverter");
} }
@Override @Override

View File

@ -20,7 +20,6 @@
package org.elasticsearch.common.io; package org.elasticsearch.common.io;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import org.elasticsearch.common.util.Callback; import org.elasticsearch.common.util.Callback;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -33,6 +32,7 @@ import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* Simple utility methods for file and stream copying. * Simple utility methods for file and stream copying.
@ -66,8 +66,8 @@ public abstract class Streams {
* @throws IOException in case of I/O errors * @throws IOException in case of I/O errors
*/ */
public static long copy(InputStream in, OutputStream out, byte[] buffer) throws IOException { public static long copy(InputStream in, OutputStream out, byte[] buffer) throws IOException {
Preconditions.checkNotNull(in, "No InputStream specified"); Objects.requireNonNull(in, "No InputStream specified");
Preconditions.checkNotNull(out, "No OutputStream specified"); Objects.requireNonNull(out, "No OutputStream specified");
try { try {
long byteCount = 0; long byteCount = 0;
int bytesRead; int bytesRead;
@ -100,8 +100,8 @@ public abstract class Streams {
* @throws IOException in case of I/O errors * @throws IOException in case of I/O errors
*/ */
public static void copy(byte[] in, OutputStream out) throws IOException { public static void copy(byte[] in, OutputStream out) throws IOException {
Preconditions.checkNotNull(in, "No input byte array specified"); Objects.requireNonNull(in, "No input byte array specified");
Preconditions.checkNotNull(out, "No OutputStream specified"); Objects.requireNonNull(out, "No OutputStream specified");
try { try {
out.write(in); out.write(in);
} finally { } finally {
@ -128,8 +128,8 @@ public abstract class Streams {
* @throws IOException in case of I/O errors * @throws IOException in case of I/O errors
*/ */
public static int copy(Reader in, Writer out) throws IOException { public static int copy(Reader in, Writer out) throws IOException {
Preconditions.checkNotNull(in, "No Reader specified"); Objects.requireNonNull(in, "No Reader specified");
Preconditions.checkNotNull(out, "No Writer specified"); Objects.requireNonNull(out, "No Writer specified");
try { try {
int byteCount = 0; int byteCount = 0;
char[] buffer = new char[BUFFER_SIZE]; char[] buffer = new char[BUFFER_SIZE];
@ -163,8 +163,8 @@ public abstract class Streams {
* @throws IOException in case of I/O errors * @throws IOException in case of I/O errors
*/ */
public static void copy(String in, Writer out) throws IOException { public static void copy(String in, Writer out) throws IOException {
Preconditions.checkNotNull(in, "No input String specified"); Objects.requireNonNull(in, "No input String specified");
Preconditions.checkNotNull(out, "No Writer specified"); Objects.requireNonNull(out, "No Writer specified");
try { try {
out.write(in); out.write(in);
} finally { } finally {

View File

@ -24,10 +24,9 @@ import org.joda.time.DateTimeZone;
import org.joda.time.MutableDateTime; import org.joda.time.MutableDateTime;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* A parser for date/time formatted text with optional date math. * A parser for date/time formatted text with optional date math.
* *
@ -40,7 +39,7 @@ public class DateMathParser {
private final FormatDateTimeFormatter dateTimeFormatter; private final FormatDateTimeFormatter dateTimeFormatter;
public DateMathParser(FormatDateTimeFormatter dateTimeFormatter) { public DateMathParser(FormatDateTimeFormatter dateTimeFormatter) {
checkNotNull(dateTimeFormatter); Objects.requireNonNull(dateTimeFormatter);
this.dateTimeFormatter = dateTimeFormatter; this.dateTimeFormatter = dateTimeFormatter;
} }

View File

@ -19,10 +19,10 @@
package org.elasticsearch.common.property; package org.elasticsearch.common.property;
import com.google.common.base.Preconditions;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
@ -61,8 +61,8 @@ public class PropertyPlaceholder {
*/ */
public PropertyPlaceholder(String placeholderPrefix, String placeholderSuffix, public PropertyPlaceholder(String placeholderPrefix, String placeholderSuffix,
boolean ignoreUnresolvablePlaceholders) { boolean ignoreUnresolvablePlaceholders) {
Preconditions.checkNotNull(placeholderPrefix, "Argument 'placeholderPrefix' must not be null."); Objects.requireNonNull(placeholderPrefix, "Argument 'placeholderPrefix' must not be null.");
Preconditions.checkNotNull(placeholderSuffix, "Argument 'placeholderSuffix' must not be null."); Objects.requireNonNull(placeholderSuffix, "Argument 'placeholderSuffix' must not be null.");
this.placeholderPrefix = placeholderPrefix; this.placeholderPrefix = placeholderPrefix;
this.placeholderSuffix = placeholderSuffix; this.placeholderSuffix = placeholderSuffix;
this.ignoreUnresolvablePlaceholders = ignoreUnresolvablePlaceholders; this.ignoreUnresolvablePlaceholders = ignoreUnresolvablePlaceholders;
@ -77,7 +77,7 @@ public class PropertyPlaceholder {
* @return the supplied value with placeholders replaced inline. * @return the supplied value with placeholders replaced inline.
*/ */
public String replacePlaceholders(String value, PlaceholderResolver placeholderResolver) { public String replacePlaceholders(String value, PlaceholderResolver placeholderResolver) {
Preconditions.checkNotNull(value, "Argument 'value' must not be null."); Objects.requireNonNull(value, "Argument 'value' must not be null.");
return parseStringValue(value, placeholderResolver, new HashSet<String>()); return parseStringValue(value, placeholderResolver, new HashSet<String>());
} }

View File

@ -22,11 +22,10 @@ package org.elasticsearch.common.util.concurrent;
import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Nullable;
import org.elasticsearch.transport.Transports; import org.elasticsearch.transport.Transports;
import java.util.Objects;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.locks.AbstractQueuedSynchronizer; import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* An abstract implementation of the {@link com.google.common.util.concurrent.ListenableFuture} interface. This * An abstract implementation of the {@link com.google.common.util.concurrent.ListenableFuture} interface. This
* class is preferable to {@link java.util.concurrent.FutureTask} for two * class is preferable to {@link java.util.concurrent.FutureTask} for two
@ -178,7 +177,7 @@ public abstract class BaseFuture<V> implements Future<V> {
* @throws Error if the throwable was an {@link Error}. * @throws Error if the throwable was an {@link Error}.
*/ */
protected boolean setException(Throwable throwable) { protected boolean setException(Throwable throwable) {
boolean result = sync.setException(checkNotNull(throwable)); boolean result = sync.setException(Objects.requireNonNull(throwable));
if (result) { if (result) {
done(); done();
} }

View File

@ -19,13 +19,14 @@
package org.elasticsearch.http; package org.elasticsearch.http;
import com.google.common.base.Preconditions;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.netty.NettyHttpServerTransport; import org.elasticsearch.http.netty.NettyHttpServerTransport;
import java.util.Objects;
/** /**
* *
*/ */
@ -50,8 +51,8 @@ public class HttpServerModule extends AbstractModule {
} }
public void setHttpServerTransport(Class<? extends HttpServerTransport> httpServerTransport, String source) { public void setHttpServerTransport(Class<? extends HttpServerTransport> httpServerTransport, String source) {
Preconditions.checkNotNull(httpServerTransport, "Configured http server transport may not be null"); Objects.requireNonNull(httpServerTransport, "Configured http server transport may not be null");
Preconditions.checkNotNull(source, "Plugin, that changes transport may not be null"); Objects.requireNonNull(source, "Plugin, that changes transport may not be null");
logger.info("Using [{}] as http transport, overridden by [{}]", httpServerTransportClass.getName(), source); logger.info("Using [{}] as http transport, overridden by [{}]", httpServerTransportClass.getName(), source);
this.httpServerTransportClass = httpServerTransport; this.httpServerTransportClass = httpServerTransport;
} }

View File

@ -19,8 +19,6 @@
package org.elasticsearch.index.engine; package org.elasticsearch.index.engine;
import com.google.common.base.Preconditions;
import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.FilterLeafReader; import org.apache.lucene.index.FilterLeafReader;
import org.apache.lucene.index.IndexCommit; import org.apache.lucene.index.IndexCommit;
@ -71,6 +69,7 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Condition;
@ -100,8 +99,8 @@ public abstract class Engine implements Closeable {
protected volatile Throwable failedEngine = null; protected volatile Throwable failedEngine = null;
protected Engine(EngineConfig engineConfig) { protected Engine(EngineConfig engineConfig) {
Preconditions.checkNotNull(engineConfig.getStore(), "Store must be provided to the engine"); Objects.requireNonNull(engineConfig.getStore(), "Store must be provided to the engine");
Preconditions.checkNotNull(engineConfig.getDeletionPolicy(), "Snapshot deletion policy must be provided to the engine"); Objects.requireNonNull(engineConfig.getDeletionPolicy(), "Snapshot deletion policy must be provided to the engine");
this.engineConfig = engineConfig; this.engineConfig = engineConfig;
this.shardId = engineConfig.getShardId(); this.shardId = engineConfig.getShardId();

View File

@ -72,7 +72,7 @@ public class PackedArrayIndexFieldData extends AbstractIndexFieldData<AtomicNume
FieldDataType fieldDataType, IndexFieldDataCache cache, NumericType numericType, FieldDataType fieldDataType, IndexFieldDataCache cache, NumericType numericType,
CircuitBreakerService breakerService) { CircuitBreakerService breakerService) {
super(index, indexSettings, fieldNames, fieldDataType, cache); super(index, indexSettings, fieldNames, fieldDataType, cache);
Preconditions.checkNotNull(numericType); Objects.requireNonNull(numericType);
Preconditions.checkArgument(EnumSet.of(NumericType.BOOLEAN, NumericType.BYTE, NumericType.SHORT, NumericType.INT, NumericType.LONG).contains(numericType), getClass().getSimpleName() + " only supports integer types, not " + numericType); Preconditions.checkArgument(EnumSet.of(NumericType.BOOLEAN, NumericType.BYTE, NumericType.SHORT, NumericType.INT, NumericType.LONG).contains(numericType), getClass().getSimpleName() + " only supports integer types, not " + numericType);
this.numericType = numericType; this.numericType = numericType;
this.breakerService = breakerService; this.breakerService = breakerService;

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.mapper; package org.elasticsearch.index.mapper;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.DocIdSet;
@ -68,6 +67,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
/** /**
@ -142,7 +142,7 @@ public class DocumentMapper implements ToXContent {
} }
public DocumentMapper build(MapperService mapperService, DocumentMapperParser docMapperParser) { public DocumentMapper build(MapperService mapperService, DocumentMapperParser docMapperParser) {
Preconditions.checkNotNull(rootObjectMapper, "Mapper builder must have the root object mapper set"); Objects.requireNonNull(rootObjectMapper, "Mapper builder must have the root object mapper set");
return new DocumentMapper(mapperService, indexSettings, docMapperParser, rootObjectMapper, meta, rootMappers, sourceTransforms, mapperService.mappingLock); return new DocumentMapper(mapperService, indexSettings, docMapperParser, rootObjectMapper, meta, rootMappers, sourceTransforms, mapperService.mappingLock);
} }
} }

View File

@ -20,11 +20,10 @@
package org.elasticsearch.index.shard; package org.elasticsearch.index.shard;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import org.apache.lucene.codecs.PostingsFormat; import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.index.CheckIndex; import org.apache.lucene.index.CheckIndex;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.QueryCachingPolicy;
import org.apache.lucene.search.*; import org.apache.lucene.search.UsageTrackingQueryCachingPolicy;
import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.ThreadInterruptedException; import org.apache.lucene.util.ThreadInterruptedException;
@ -110,10 +109,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.nio.channels.ClosedByInterruptException; import java.nio.channels.ClosedByInterruptException;
import java.util.Arrays; import java.util.*;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -207,8 +203,8 @@ public class IndexShard extends AbstractIndexShardComponent {
this.deletionPolicy = deletionPolicy; this.deletionPolicy = deletionPolicy;
this.similarityService = similarityService; this.similarityService = similarityService;
this.wrappingService = wrappingService; this.wrappingService = wrappingService;
Preconditions.checkNotNull(store, "Store must be provided to the index shard"); Objects.requireNonNull(store, "Store must be provided to the index shard");
Preconditions.checkNotNull(deletionPolicy, "Snapshot deletion policy must be provided to the index shard"); Objects.requireNonNull(deletionPolicy, "Snapshot deletion policy must be provided to the index shard");
this.engineFactory = factory; this.engineFactory = factory;
this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle; this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle;
this.indexSettingsService = indexSettingsService; this.indexSettingsService = indexSettingsService;

View File

@ -19,7 +19,6 @@
package org.elasticsearch.transport; package org.elasticsearch.transport;
import com.google.common.base.Preconditions;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
@ -31,6 +30,7 @@ import org.elasticsearch.transport.netty.NettyTransport;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* *
@ -107,15 +107,15 @@ public class TransportModule extends AbstractModule {
} }
public void setTransportService(Class<? extends TransportService> transportService, String source) { public void setTransportService(Class<? extends TransportService> transportService, String source) {
Preconditions.checkNotNull(transportService, "Configured transport service may not be null"); Objects.requireNonNull(transportService, "Configured transport service may not be null");
Preconditions.checkNotNull(source, "Plugin, that changes transport service may not be null"); Objects.requireNonNull(source, "Plugin, that changes transport service may not be null");
this.configuredTransportService = transportService; this.configuredTransportService = transportService;
this.configuredTransportServiceSource = source; this.configuredTransportServiceSource = source;
} }
public void setTransport(Class<? extends Transport> transport, String source) { public void setTransport(Class<? extends Transport> transport, String source) {
Preconditions.checkNotNull(transport, "Configured transport may not be null"); Objects.requireNonNull(transport, "Configured transport may not be null");
Preconditions.checkNotNull(source, "Plugin, that changes transport may not be null"); Objects.requireNonNull(source, "Plugin, that changes transport may not be null");
this.configuredTransport = transport; this.configuredTransport = transport;
this.configuredTransportSource = source; this.configuredTransportSource = source;
} }

View File

@ -94,3 +94,6 @@ com.google.common.base.Strings
com.google.common.base.Throwables com.google.common.base.Throwables
com.google.common.collect.Maps com.google.common.collect.Maps
com.google.common.collect.Sets com.google.common.collect.Sets
com.google.common.base.Preconditions#checkNotNull(java.lang.Object)
com.google.common.base.Preconditions#checkNotNull(java.lang.Object, java.lang.Object)
com.google.common.base.Preconditions#checkNotNull(java.lang.Object, java.lang.String, java.lang.Object[])

View File

@ -2,8 +2,7 @@
== Integrations == Integrations
Integrations are not plugins, instead they are external tools or modules which Integrations are not plugins, but are external tools or modules that make it easier to work with Elasticsearch.
make it easier to work with Elasticsearch.
[float] [float]
[[cms-integrations]] [[cms-integrations]]
@ -29,13 +28,24 @@ make it easier to work with Elasticsearch.
search (facets, etc), along with some Natural Language Processing features search (facets, etc), along with some Natural Language Processing features
(ex.: More like this) (ex.: More like this)
[float] [float]
[[data-integrations]] [[data-integrations]]
=== Data import/export and validation === Data import/export and validation
NOTE: Rivers were used to import data from external systems into NOTE: Rivers were used to import data from external systems into Elasticsearch prior to the 2.0 release. Elasticsearch
Elasticsearch, but they are no longer supported in Elasticsearch 2.0. releases 2.0 and later do not support rivers.
[float]
==== Supported by the community:
* https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html[Logstash output to Elasticsearch]:
The Logstash `elasticsearch` output plugin.
* https://www.elastic.co/guide/en/logstash/current/plugins-inputs-elasticsearch.html[Elasticsearch input to Logstash]
The Logstash `elasticsearch` input plugin.
* https://www.elastic.co/guide/en/logstash/current/plugins-filters-elasticsearch.html[Elasticsearch event filtering in Logstash]
The Logstash `elasticearch` filter plugin.
* https://www.elastic.co/guide/en/logstash/current/plugins-codecs-es_bulk.html[Elasticsearch bulk codec]
The Logstash `es_bulk` plugin decodes the Elasticsearch bulk format into individual events.
[float] [float]
==== Supported by the community: ==== Supported by the community:
@ -44,15 +54,14 @@ Elasticsearch, but they are no longer supported in Elasticsearch 2.0.
The Java Database Connection (JDBC) importer allows to fetch data from JDBC sources for indexing into Elasticsearch (by Jörg Prante) The Java Database Connection (JDBC) importer allows to fetch data from JDBC sources for indexing into Elasticsearch (by Jörg Prante)
* https://github.com/reachkrishnaraj/kafka-elasticsearch-standalone-consumer[Kafka Standalone Consumer]: * https://github.com/reachkrishnaraj/kafka-elasticsearch-standalone-consumer[Kafka Standalone Consumer]:
Easily Scaleable & Extendable, Kafka Standalone Consumer that will read the messages from Kafka, processes and index them in ElasticSearch Easily Scalable & Extendable Kafka Standalone Consumer that reads messages from Kafka, then processes and indexes the messages in ElasticSearch
* https://github.com/ozlerhakan/mongolastic[Mongolastic]: * https://github.com/ozlerhakan/mongolastic[Mongolastic]:
A tool that clone data from ElasticSearch to MongoDB and vice versa A tool that clones data from ElasticSearch to MongoDB and vice versa
* https://github.com/Aconex/scrutineer[Scrutineer]: * https://github.com/Aconex/scrutineer[Scrutineer]:
A high performance consistency checker to compare what you've indexed A high performance consistency checker to compare what you've indexed
with your source of truth content (e.g. DB) with your source of truth content
[float] [float]
[[deployment]] [[deployment]]
@ -207,7 +216,7 @@ These projects appear to have been abandoned:
Protocol dissection for Zen discovery, HTTP and the binary protocol Protocol dissection for Zen discovery, HTTP and the binary protocol
These projects appears to have been abandoned: These projects appear to have been abandoned:
* http://www.github.com/neogenix/daikon[daikon]: * http://www.github.com/neogenix/daikon[daikon]:
Daikon Elasticsearch CLI Daikon Elasticsearch CLI
@ -216,5 +225,4 @@ These projects appears to have been abandoned:
A set of AngularJS directives that provide common visualizations for elasticsearch based on A set of AngularJS directives that provide common visualizations for elasticsearch based on
D3. D3.
* https://github.com/OlegKunitsyn/eslogd[eslogd]: * https://github.com/OlegKunitsyn/eslogd[eslogd]:
Linux daemon that replicates events to a central Elasticsearch server in real-time Linux daemon that replicates events to a central Elasticsearch server in realtime