NullPointerException in ProfileEventAdapter.completed(ProfileEventAdapter.java:72)

After upgrading to gradle 2.0 we started seeing this NPE. We didn’t see this in the initial QA. It wasn’t until we started running a lot of concurrent jobs that this started happening.

Not sure what other info to provide. It’s not a stack trace that I’ve seen anywhere else in this forum or in jira.

Here’s the env:

#> gradle -version
  ------------------------------------------------------------
Gradle 2.0
------------------------------------------------------------
  Build time:
 2014-07-01 07:45:34 UTC
Build number: none
Revision:
   b6ead6fa452dfdadec484059191eb641d817226c
  Groovy:
     2.3.3
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

We’ve been building each job in it’s own --gradle-user-home to get around https://issues.gradle.org/browse/GRADLE-3106.

gradle --no-daemon -i -b /opt/nim/parserV4/build.gradle -Pcfg=/cbdata/root/rg/chf/2014-07-01/job/151726/buildjob.json -Pstandalone= --stacktrace --gradle-user-home=/cbdata/root/rg/chf/2014-07-01/job/151726/.gradle --project-cache-dir /cbdata/root/rg/chf/2014-07-01/job/151726/.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:72)
 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:193)
 at org.gradle.initialization.buildsrc.BuildSourceBuilder.createBuildSourceClasspath(BuildSourceBuilder.java:80)
 at org.gradle.initialization.buildsrc.BuildSourceBuilder.buildAndCreateClassLoader(BuildSourceBuilder.java:51)
 at org.gradle.initialization.SettingsHandler.findSettingsAndLoadIfAppropriate(SettingsHandler.java:86)
 at org.gradle.initialization.SettingsHandler.findAndLoadSettings(SettingsHandler.java:46)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:120)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:105)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:85)
 at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:81)
 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:39)
 at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29)
 at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
 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)

Seeing this in gradle 2.1 as well. Trace line numbers slightly different but it’s the same problem. This is current bug.

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)

Can a JIRA issue be created to track this issue? We are seeing this frequently during the development of Grails 3.0 (master branch)

Raised GRADLE-3200.

Thag/Graeme,

can you give exact steps to reproduce your problem? I have a theory that something wrong happens very early during the build initialization and the build fails and tries to run regular finish sequence but the ProfileEventAdapter wasn’t even initialized and throws this NPE. Knowing what exactly happens will help us to apply a fix with confidence rather than doing just some poor workaround.

Possibly there can also be some additional information in Gradle log.

I haven’t seen the issue for a while with the latest build snapshots of Gradle, so maybe it has been resolved already. It was reproducible simply by using the Gradle tooling API to run a command in 2.2 final

OK, we can wait for a while and close the bug if there is no update from you before 2.3 release.

Is there a specific milestone build we should try to see if this is still reproducible?

You can use the nightly build.

http://gradle.org/nightly

I see the same NullPointerException in 2.2. I only see this when running in a docker container. I also tried distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-2.4-20141229230057+0000-bin.zip and get the same error

Seeing this after changing the system locale to Japanese:

https://gist.github.com/awesomeamyg/1269cbbc0fc76e6befb2