explicitly pass null values to methods where applicable

This commit is contained in:
kimchy 2010-12-30 13:09:11 +02:00
parent 5a45e9c8bd
commit 76d042f3c5
7 changed files with 14 additions and 12 deletions

View File

@ -42,6 +42,7 @@ import org.elasticsearch.search.internal.InternalSearchRequest;
import org.elasticsearch.search.query.QuerySearchResultProvider;
import org.elasticsearch.threadpool.ThreadPool;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
@ -136,7 +137,7 @@ public abstract class TransportSearchTypeAction extends BaseAction<SearchRequest
}
} else {
// really, no shards active in this group
onFirstPhaseResult(shard, shardIt, null);
onFirstPhaseResult(null, shardIt, null);
}
}
// we have local operations, perform them now
@ -184,7 +185,7 @@ public abstract class TransportSearchTypeAction extends BaseAction<SearchRequest
final ShardRouting shard = shardIt.nextActiveOrNull();
if (shard == null) {
// no more active shards... (we should not really get here, but just for safety)
onFirstPhaseResult(shard, shardIt, null);
onFirstPhaseResult(null, shardIt, null);
} else {
DiscoveryNode node = nodes.get(shard.currentNodeId());
if (node == null) {
@ -229,7 +230,7 @@ public abstract class TransportSearchTypeAction extends BaseAction<SearchRequest
}
}
private void onFirstPhaseResult(ShardRouting shard, final ShardIterator shardIt, Throwable t) {
private void onFirstPhaseResult(@Nullable ShardRouting shard, final ShardIterator shardIt, Throwable t) {
if (totalOps.incrementAndGet() == expectedTotalOps) {
// e is null when there is no next active....
if (logger.isDebugEnabled()) {

View File

@ -40,6 +40,7 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.*;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@ -179,7 +180,7 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
}
} else {
// really, no shards active in this group
onOperation(shard, shardIt, null, false);
onOperation(null, shardIt, null, false);
}
}
// we have local operations, perform them now
@ -219,7 +220,7 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
final ShardRouting shard = nextShardOrNull(shardIt);
if (shard == null) {
// no more active shards... (we should not really get here, just safety)
onOperation(shard, shardIt, null, false);
onOperation(null, shardIt, null, false);
} else {
final ShardRequest shardRequest = newShardRequest(shard, request);
if (shard.currentNodeId().equals(nodes.localNodeId())) {
@ -278,7 +279,7 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
}
@SuppressWarnings({"unchecked"})
private void onOperation(ShardRouting shard, final ShardIterator shardIt, Throwable t, boolean alreadyThreaded) {
private void onOperation(@Nullable ShardRouting shard, final ShardIterator shardIt, Throwable t, boolean alreadyThreaded) {
if (!hasNextShard(shardIt)) {
// e is null when there is no next active....
if (logger.isDebugEnabled()) {

View File

@ -180,7 +180,7 @@ public abstract class NetworkUtils {
}
}
} else {
throw new UnknownHostException("network interface " + intf + " not found");
throw new UnknownHostException("network interface not found");
}
return supportsVersion;
}

View File

@ -71,7 +71,7 @@ public class CustomScoreQueryBuilder extends BaseQueryBuilder {
* Additional parameters that can be provided to the script.
*/
public CustomScoreQueryBuilder params(Map<String, Object> params) {
if (params == null) {
if (this.params == null) {
this.params = params;
} else {
this.params.putAll(params);

View File

@ -54,7 +54,7 @@ public class ScriptFilterBuilder extends BaseFilterBuilder {
}
public ScriptFilterBuilder params(Map<String, Object> params) {
if (params == null) {
if (this.params == null) {
this.params = params;
} else {
this.params.putAll(params);

View File

@ -433,7 +433,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
throw new ElasticSearchIllegalStateException("Can't add nodes to a stopped transport");
}
if (node == null) {
throw new ConnectTransportException(node, "Can't connect to a null node");
throw new ConnectTransportException(null, "Can't connect to a null node");
}
try {
NodeChannels nodeChannels = connectedNodes.get(node);

View File

@ -261,11 +261,11 @@ public class IndexLifecycleActionTests extends AbstractNodesTests {
clusterState1 = clusterService1.state();
routingNodeEntry1 = clusterState1.readOnlyRoutingNodes().nodesToShards().get(clusterState1.nodes().localNodeId());
assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED), anyOf(equalTo(5), equalTo(3)));
assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED), anyOf(equalTo(5), equalTo(4), equalTo(3)));
clusterState2 = clusterService2.state();
routingNodeEntry2 = clusterState2.readOnlyRoutingNodes().nodesToShards().get(clusterState2.nodes().localNodeId());
assertThat(routingNodeEntry2.numberOfShardsWithState(STARTED), anyOf(equalTo(5), equalTo(3)));
assertThat(routingNodeEntry2.numberOfShardsWithState(STARTED), anyOf(equalTo(5), equalTo(4), equalTo(3)));
ClusterState clusterState3 = clusterService3.state();
RoutingNode routingNodeEntry3 = clusterState3.readOnlyRoutingNodes().nodesToShards().get(clusterState3.nodes().localNodeId());