spinscale/elasticsearch-graphite-plugin — pull request #1 by blakesmith (2013-04-10 02:54:56+00:00)
Title: Handle null lastGc

Hey there!

After installing the plugin and enabling DEBUG logging, I was seeing stacktraces in the elasticsearch log:

```
[2013-04-09 21:36:31,846][DEBUG][org.elasticsearch.service.graphite.GraphiteReporter] Error writing to Graphite
java.lang.NullPointerException
at org.elasticsearch.service.graphite.GraphiteReporter.sendNodeJvmStats(GraphiteReporter.java:199)
at org.elasticsearch.service.graphite.GraphiteReporter.sendNodeStats(GraphiteReporter.java:83)
at org.elasticsearch.service.graphite.GraphiteReporter.run(GraphiteReporter.java:68)
at org.elasticsearch.service.graphite.GraphiteService$GraphiteReporterThread.run(GraphiteService.java:87)
at java.lang.Thread.run(Thread.java:679)
```

It looks like `lastGc` is null. Digging into the elasticsearch source, it appears that this is a valid state (see: https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java#L184)

What do you think? Is this guard the right way to prevent this NPE, or is there some other better way to fix this?

Thanks a bunch for the plugin!

Blake