[GRADLE-2626] Obscure error message when one of arguments for Exec task is NULL Created: 11/Jan/13  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 1.3
Fix Version/s: None

Type: Improvement
Reporter: Vitaliy Garnashevich Assignee: Unassigned
Resolution: Won't Fix Votes: 0

Known Issue Of:
1.3

 Description   

Minimal Gradle script, which reproduces the problem:

exec {
    commandLine = ["keytool", null]
}

Output:

FAILURE: Build failed with an exception.

* Where:
Build file 'R:\build.gradle' line: 3

* What went wrong:
A problem occurred evaluating root project ''.
> java.lang.NullPointerException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.838 secs

Output (when run with -s):

FAILURE: Build failed with an exception.

* Where:
Build file 'R:\build.gradle' line: 3

* What went wrong:
A problem occurred evaluating root project ''.
> java.lang.NullPointerException (no error message)

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project ''.
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
	at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
	at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:463)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:75)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
	at org.gradle.api.internal.Actions$CompositeAction.execute(Actions.java:67)
	at org.gradle.api.internal.Actions$TransformingActionAdapter.execute(Actions.java:96)
	at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:439)
	at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:434)
	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:32)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
	at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)
	at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
	at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25)
	at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
	at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:137)
	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
	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:48)
	at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
	at org.gradle.launcher.Main.main(Main.java:39)
	at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
	at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: java.lang.NullPointerException
	at org.gradle.process.internal.ExecHandleBuilder.getArgs(ExecHandleBuilder.java:93)
	at org.gradle.process.internal.ExecHandleBuilder.getAllArguments(ExecHandleBuilder.java:100)
	at org.gradle.process.internal.AbstractExecHandleBuilder.build(AbstractExecHandleBuilder.java:127)
	at org.gradle.process.internal.DefaultExecAction.execute(DefaultExecAction.java:36)
	at org.gradle.api.internal.file.DefaultFileOperations.exec(DefaultFileOperations.java:160)
	at org.gradle.api.internal.project.AbstractProject.exec(AbstractProject.java:819)
	at org.gradle.groovy.scripts.DefaultScript.exec(DefaultScript.java:173)
	at org.gradle.api.Script$exec.callCurrent(Unknown Source)
	at build_1ssljojjkmjkqe7clspn3gdk70.run(R:\build.gradle:3)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
	... 32 more

BUILD FAILED

Total time: 13.163 secs

I'm just learning to use Gradle, and it took me some time to figure out why my script fails (e.g. maybe I'm missing some task argument, or maybe I'm using the task incorrectly, etc.).

Gradle should produce more specific error message instead of general NPE.



 Comments   
Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 12:27:03 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.