Fix possible NPE in TransportNodesListGatewayStartedShards operation

This commit is contained in:
Igor Motov 2011-11-04 15:43:37 -04:00 committed by Shay Banon
parent c5ebe6e86f
commit eafa2b0c9a
1 changed files with 7 additions and 4 deletions

View File

@ -111,10 +111,13 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat
}
@Override protected NodeLocalGatewayStartedShards nodeOperation(NodeRequest request) throws ElasticSearchException {
for (Map.Entry<ShardId, Long> entry : gateway.currentStartedShards().shards().entrySet()) {
if (entry.getKey().equals(request.shardId)) {
assert entry.getValue() != null;
return new NodeLocalGatewayStartedShards(clusterService.localNode(), entry.getValue());
LocalGatewayStartedShards startedShards = gateway.currentStartedShards();
if (startedShards != null) {
for (Map.Entry<ShardId, Long> entry : startedShards.shards().entrySet()) {
if (entry.getKey().equals(request.shardId)) {
assert entry.getValue() != null;
return new NodeLocalGatewayStartedShards(clusterService.localNode(), entry.getValue());
}
}
}
return new NodeLocalGatewayStartedShards(clusterService.localNode(), -1);