NullPointerException in ProfileEventAdapter.completed ProfileEventAdapter.java in gradle 2.0 & 2.1

Re-filing this as a problem rather than a question, from http://forums.gradle.org/gradle/topics/nullpointerexception-in-profileeventadapter-completed-profileeventadapter-java-72

This is a problem since upgrading to gradle 2.0.

Env:

------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------
  Build time:
 2014-09-08 10:40:39 UTC
Build number: none
Revision:
   e6cf70745ac11fa943e19294d19a2c527a669a53
  Groovy:
     2.3.6
Ant:
        Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:
        1.7.0_55 (Oracle Corporation 24.55-b03)
OS:
         Linux 3.11.0-18-generic amd64

Here’s the command line & trace. Note the cache & home dir options are to work around GRADLE-3106.

gradle --no-daemon -i -b /opt/nim/parserV4/build.gradle -Pcfg=/cbdata/root/enm/ent/2014-05-25/job/151110/buildjob.json -Pstandalone= --stacktrace --gradle-user-home=/cbdata/root/enm/ent/2014-05-25/job/151110/.gradle --project-cache-dir /cbdata/root/enm/ent/2014-05-25/job/151110/.gradle run -PmergeOption=MERGEINDEX
Starting Build
================================================ Start building buildSrc
  FAILURE: Build failed with an exception.
  * What went wrong:
java.lang.NullPointerException (no error message)
  * Try:
Run with --debug option to get more log output.
  * Exception is:
java.lang.NullPointerException
        at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy16.completed(Unknown Source)
        at org.gradle.initialization.DefaultGradleLauncher.stop(DefaultGradleLauncher.java:194)
        at org.gradle.initialization.buildsrc.BuildSourceBuilder.createBuildSourceClasspath(BuildSourceBuilder.java:84)
        at org.gradle.initialization.buildsrc.BuildSourceBuilder.buildAndCreateClassLoader(BuildSourceBuilder.java:55)
        at org.gradle.initialization.SettingsHandler.findSettingsAndLoadIfAppropriate(SettingsHandler.java:104)
        at org.gradle.initialization.SettingsHandler.findAndLoadSettings(SettingsHandler.java:48)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:121)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

Some additional information. It appears that it has some dependence on other gradle instances even thought they are using different cache & home directories. This is evidenced from the fact that after building thousands of jobs, it happened on at the same exact time on multiple separate gradle invocations:

Note the time stamps.

%> grep
'org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)' */bui*
2014-11-18_14:37:28/build_144173_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)
2014-11-18_14:37:28/build_150068_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)
2014-11-18_14:37:28/build_151110_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)
2014-11-18_14:37:28/build_152139_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)

and again later:

2014-11-18_17:35:08/build_139720_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)
2014-11-18_17:35:08/build_144147_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)
2014-11-18_17:35:08/build_144164_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)
2014-11-18_17:35:08/build_153015_None.log:
    at org.gradle.profile.ProfileEventAdapter.completed(ProfileEventAdapter.java:74)