tlrx / elasticsearch-test

elasticsearch-test, a framework that makes elasticsearch unit testing a breeze.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPE Caused By JDK 7 Bug on OS X

bflad opened this issue · comments

I was getting NPE from this line:
https://github.com/tlrx/elasticsearch-test/blob/master/src/main/java/com/github/tlrx/elasticsearch/test/provider/LocalClientProvider.java#L91

java.lang.NullPointerException
    at com.github.tlrx.elasticsearch.test.provider.LocalClientProvider.buildNodeSettings(LocalClientProvider.java:88)
    at com.github.tlrx.elasticsearch.test.provider.LocalClientProvider.open(LocalClientProvider.java:53)
    at com.github.tlrx.elasticsearch.test.EsSetup.execute(EsSetup.java:130)

Related to an obscure bug in JDK 7 on OS X using a DHCP IP:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7180557

The fix is really easy since the cluster.name isn't critical, it could either:

  • Hard set "elasticsearch-test-localhost"
  • try/catch around the getLocalAddress and set "localhost" by default

If you'd like me to submit a PR, I can try, but my Java skills aren't the best.

It should be fixed in latest releases of JDK 7, please reopen if it's not the case.