elasticsearch/elasticsearch — pull request #1440 by imotov (2011-11-04 21:00:28+00:00)
Title: Fix possible NPE in TransportNodesListGatewayStartedShards operation

When recovering cluster contains data nodes with no shards on them, the TransportNodesListGatewayStartedShards fails with the following exception:

```
[2011-11-04 10:43:28,611][DEBUG][gateway.local ] [Hulk 2099] failed to execute on node [gxylYRQ-Tp-EFlRRXgOgHQ]
org.elasticsearch.transport.RemoteTransportException: [Sandman][inet[/10.1.10.148:9301]][/gateway/local/started-shards/node]
Caused by: java.lang.NullPointerException
at org.elasticsearch.gateway.local.TransportNodesListGatewayStartedShards.nodeOperation(TransportNodesListGatewayStartedShards.java:114)
at org.elasticsearch.gateway.local.TransportNodesListGatewayStartedShards.nodeOperation(TransportNodesListGatewayStartedShards.java:49)
at org.elasticsearch.action.support.nodes.TransportNodesOperationAction$NodeTransportHandler.messageReceived(TransportNodesOperationAction.java:267)
at org.elasticsearch.action.support.nodes.TransportNodesOperationAction$NodeTransportHandler.messageReceived(TransportNodesOperationAction.java:260)
at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:238)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
```

I am not sure if it affects recovery.

To reproduce:

- delete data directory
- start one node with default settings
- create one index with default settings
- shut down the node
- add `gateway.recover_after_nodes: 3` to elasticsearch.yml
- add `gateway: DEBUG` to logging.yml
- start 3 nodes
- observe error message above in the log file