Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356666

Summary: nested quotes in ${tycho.testArgLine} may lead to NPE
Product: z_Archived Reporter: Steffen Pingel <steffen.pingel>
Component: TychoAssignee: Jan Sievers <jan.sievers>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: jan.sievers
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:

Description Steffen Pingel CLA 2011-09-03 11:01:46 EDT
Since the last 0.13 snapshot update Mylyn tests started to fail.

http://ci.mylyn.org/job/mylyn-tasks-trigger/20/console

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.13.0-SNAPSHOT:test (default-test) on project org.eclipse.mylyn.tasks.tests: Error while executing platform: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.13.0-SNAPSHOT:test (default-test) on project org.eclipse.mylyn.tasks.tests: Error while executing platform
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error while executing platform
	at org.eclipse.tycho.surefire.TestMojo.runTest(TestMojo.java:560)
	at org.eclipse.tycho.surefire.TestMojo.execute(TestMojo.java:361)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
	... 19 more
Caused by: java.lang.NullPointerException
	at org.eclipse.tycho.equinox.launching.internal.EquinoxLaunchConfiguration.toStringArray(EquinoxLaunchConfiguration.java:94)
	at org.eclipse.tycho.equinox.launching.internal.EquinoxLaunchConfiguration.getVMArguments(EquinoxLaunchConfiguration.java:113)
	at org.eclipse.tycho.equinox.launching.internal.DefaultEquinoxLauncher.execute(DefaultEquinoxLauncher.java:49)
	at org.eclipse.tycho.surefire.TestMojo.runTest(TestMojo.java:558)
Comment 1 Steffen Pingel CLA 2011-09-03 11:23:01 EDT
Turns out this was not related to a Tycho update but caused by a change to the Hudson job configuration. Nested quotes seems to throw off Tycho: '-Dtest.vmargs="-ea -Dorg.eclipse.mylyn.wikitext.tests.disableOutput=true"'

I changed that to "-Dtest.vmargs=-ea -Dorg.eclipse.mylyn.wikitext.tests.disableOutput=true" to fix it (the tests.vmargs property is passed to the surefire plug-in).

I'll leave this bug open since it would be helpful if the error handling was improved.


Full command that was failing:

mvn clean verify -V -e "-DGERRIT_CHANGE_SUBJECT=ASSIGNED - bug 305169: Use different color for attachments marked with iplog flag  https://bugs.eclipse.org/bugs/show_bug.cgi?id=305169" -DGERRIT_REFSPEC=refs/changes/15/15/1 -DGERRIT_BRANCH=master -DGERRIT_PATCHSET_NUMBER=1 -DGERRIT_CHANGE_URL=http://ci.mylyn.org/15 -DGERRIT_CHANGE_ID=Ibf22fe0d7a20189f83d37eb77f301deeb184f6be -DGERRIT_PATCHSET_REVISION=98359ac327a5e7b32b1e8427544ca5f310d8db68 -DGERRIT_CHANGE_NUMBER=15 -DGERRIT_PROJECT=org.eclipse.mylyn.tasks -Dmaven.test.failure.ignore=true '-Dtest.vmargs="-ea -Dorg.eclipse.mylyn.wikitext.tests.disableOutput=true"' -Dmaven.ext.class.path=/home/hudson/.hudson/maven/slavebundle/resources:/home/hudson/.hudson/maven/slavebundle/lib/maven3-eventspy-3.0.jar:/home/hudson/.hudson/war/WEB-INF/lib/hudson-remoting-2.1.1.jar -Dhudson.eventspy.port=34587 -f pom.xml -fae
Comment 2 Jan Sievers CLA 2014-02-26 08:49:26 EST
I revisited this issue while fixing bug 427556.

You can reproduce it by adding a surefire configuration e.g. in tycho-demo/itp01

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-surefire-plugin</artifactId>
        <version>${tycho-version}</version>
        <configuration>
		  <argLine>${test.vmargs}</argLine>
        </configuration>
      </plugin>


and starting the build using

mvn clean verify '-Dtest.vmargs="-ea -Dorg.eclipse.mylyn.wikitext.tests.disableOutput=true"' -X -e

you will see in the debug build log:

[DEBUG]   (f) argLine = "-ea -Dorg.eclipse.mylyn.wikitext.tests.disableOutput=true

Note the unbalanced quotes (probably eaten up by the shell process/java process that started mvn)

The unbalanced quotes are the root cause, however the root cause is hidden by plexus utils which catch any Exception while parsing the line

https://github.com/sonatype/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/cli/Commandline.java#L784

You can also see in the build log

"Error translating Commandline."

This unspecific message masks the more specific exception 

            throw new CommandLineException( "unbalanced quotes in " + toProcess );

being caught.
See https://github.com/sonatype/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/cli/CommandLineUtils.java#L377

This leaves String[] parts as null causing the follow up NPE.
Comment 3 Jan Sievers CLA 2014-02-27 04:30:28 EST
https://git.eclipse.org/r/#/c/22606/