check for null on setters taht must not be null in IndicesReplicationOperationRequest

This commit is contained in:
Simon Willnauer 2013-03-07 10:17:34 +01:00
parent 35f5ca915d
commit 2c8d8ef8e0
2 changed files with 12 additions and 2 deletions

View File

@ -72,6 +72,9 @@ public class IndicesReplicationOperationRequest<T extends IndicesReplicationOper
} }
public T ignoreIndices(IgnoreIndices ignoreIndices) { public T ignoreIndices(IgnoreIndices ignoreIndices) {
if (ignoreIndices == null) {
throw new IllegalArgumentException("IgnoreIndices must not be null");
}
this.ignoreIndices = ignoreIndices; this.ignoreIndices = ignoreIndices;
return (T) this; return (T) this;
} }
@ -94,6 +97,9 @@ public class IndicesReplicationOperationRequest<T extends IndicesReplicationOper
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final T replicationType(ReplicationType replicationType) { public final T replicationType(ReplicationType replicationType) {
if (replicationType == null) {
throw new IllegalArgumentException("ReplicationType must not be null");
}
this.replicationType = replicationType; this.replicationType = replicationType;
return (T) this; return (T) this;
} }
@ -114,6 +120,9 @@ public class IndicesReplicationOperationRequest<T extends IndicesReplicationOper
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final T consistencyLevel(WriteConsistencyLevel consistencyLevel) { public final T consistencyLevel(WriteConsistencyLevel consistencyLevel) {
if (consistencyLevel == null) {
throw new IllegalArgumentException("WriteConsistencyLevel must not be null");
}
this.consistencyLevel = consistencyLevel; this.consistencyLevel = consistencyLevel;
return (T) this; return (T) this;
} }

View File

@ -84,8 +84,9 @@ public class RestDeleteByQueryAction extends BaseRestHandler {
if (consistencyLevel != null) { if (consistencyLevel != null) {
deleteByQueryRequest.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel)); deleteByQueryRequest.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
} }
if (request.hasParam("ignore_indices")) { final String ignoreIndices = request.param("ignore_indices");
deleteByQueryRequest.ignoreIndices(IgnoreIndices.fromString(request.param("ignore_indices"))); if (ignoreIndices != null) {
deleteByQueryRequest.ignoreIndices(IgnoreIndices.fromString(ignoreIndices));
} }
} catch (Exception e) { } catch (Exception e) {
try { try {