# Periodic NullPointerExceptions in HeartBeatEvent running \`gradle test\` in OS X

**URL:** <https://discuss.elastic.co/t/periodic-nullpointerexceptions-in-heartbeatevent-running-gradle-test-in-os-x/91014>\
**Category:** Elasticsearch\
**Created:** [June 27, 2017, 6:45pm UTC](https://discuss.elastic.co/t/periodic-nullpointerexceptions-in-heartbeatevent-running-gradle-test-in-os-x/91014 "2017-06-27T18:45:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [June 27, 2017, 6:45pm UTC](https://discuss.elastic.co/t/periodic-nullpointerexceptions-in-heartbeatevent-running-gradle-test-in-os-x/91014/1 "2017-06-27T18:45:48Z")

</div>

I've been trying to resolve an issue in an Elasticsearch plugin I maintain. This plugin builds fine for others in Ubuntu, but a fresh build in OS X is producing pretty inscrutable test failures.

To see if it was me, I brought down Elasticsearch source and ran `gradle test` and indeed I've gotten the same errors, listed at the bottom. Only a couple of tests are failing, most pass. But some randomly fail.

Is this something known on OS X? Is there a workaround? Searching hasn't turned up anything (but my google-fu may be weak)

```auto
Exception thrown by subscriber method onHeartbeat(com.carrotsearch.ant.tasks.junit4.events.aggregated.HeartBeatEvent) on subscriber com.carrotsearch.gradle.junit4.TestReportLogger@52ca2fa9 when dispatching event: com.carrotsearch.ant.tasks.junit4.events.aggregated.HeartBeatEvent@3fa57c62
java.lang.NullPointerException
        at com.carrotsearch.ant.tasks.junit4.ForkedJvmInfo.getPidString(ForkedJvmInfo.java:85)
        at com.carrotsearch.ant.tasks.junit4.ForkedJvmInfo$getPidString.call(Unknown Source)
        at com.carrotsearch.gradle.junit4.TestReportLogger.onHeartbeat(TestReportLogger.groovy:116)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:95)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:154)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$1.run(Subscriber.java:80)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:76)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:119)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.EventBus.post(EventBus.java:215)
        at com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatingListener.slowHeartBeat(AggregatingListener.java:76)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:95)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:154)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$1.run(Subscriber.java:80)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:76)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:119)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.EventBus.post(EventBus.java:215)
        at com.carrotsearch.ant.tasks.junit4.LocalSlaveStreamHandler$3.run(LocalSlaveStreamHandler.java:149)

```

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [June 27, 2017, 7:07pm UTC](https://discuss.elastic.co/t/periodic-nullpointerexceptions-in-heartbeatevent-running-gradle-test-in-os-x/91014/2 "2017-06-27T19:07:54Z")

</div>

Build Hamster Info:

```auto
=======================================
Elasticsearch Build Hamster says Hello!
=======================================
  Gradle Version : 4.0
  OS Info : Mac OS X 10.12.5 (x86_64)
  JDK Version : Oracle Corporation 1.8.0_131 [Java HotSpot(TM) 64-Bit Server VM 25.131-b11]
  JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0

```

Seen building Elasticsearch trunk and 5.4.0

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [June 29, 2017, 1:17am UTC](https://discuss.elastic.co/t/periodic-nullpointerexceptions-in-heartbeatevent-running-gradle-test-in-os-x/91014/3 "2017-06-29T01:17:48Z")

</div>

In case anyone comes across this in the future, I _think_ this is a randomized testing issue with a log statement that's actually not a big deal. See [here](https://github.com/randomizedtesting/randomizedtesting/issues/250)

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [June 29, 2017, 1:21am UTC](https://discuss.elastic.co/t/periodic-nullpointerexceptions-in-heartbeatevent-running-gradle-test-in-os-x/91014/4 "2017-06-29T01:21:47Z")

</div>

Also the fact that the build failed was unrelated to this stack trace. It failed because I had `ES_HEAP_SIZE` set in my environment from a project that uses ES 2.x. Elasticsearch integration tests (or something in the build pipeline) detects this is set and issues a failure.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 27, 2017, 1:22am UTC](https://discuss.elastic.co/t/periodic-nullpointerexceptions-in-heartbeatevent-running-gradle-test-in-os-x/91014/5 "2017-07-27T01:22:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
