Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6105

properties.internal.SystemProperties.addSystemProperties() is not really thread-safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.3.9
    • 3.5.0-alpha-1, 3.5.0
    • Core
    • None

    Description

      We got a rather large Maven project with a couble of modules that execute maven-assembly-plugin. Our build runs in parallel mode via -Tx.
      From time to time we are seeing following exception causing the respective build to fail:

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (assembly-zip) on project some-module: Execution assembly-zip of goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single failed. NullPointerException -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (assembly-zip) on project some-module: Execution assembly-zip of goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single failed.
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
      	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:116)
      	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:185)
      	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:181)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.apache.maven.plugin.PluginExecutionException: Execution assembly-zip of goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single failed.
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
      	... 11 more
      Caused by: java.lang.NullPointerException
      	at java.util.Hashtable.put(Hashtable.java:459)
      	at org.apache.maven.properties.internal.SystemProperties.addSystemProperties(SystemProperties.java:38)
      	at org.apache.maven.project.artifact.MavenMetadataSource.getSystemProperties(MavenMetadataSource.java:756)
      	at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:574)
      	at org.apache.maven.project.artifact.MavenMetadataSource.retrieve(MavenMetadataSource.java:190)
      	at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:532)
      	at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:584)
      	at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:144)
      	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:493)
      	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveWithExceptions(DefaultArtifactResolver.java:348)
      	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:342)
      	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:321)
      	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:286)
      	at org.apache.maven.plugin.assembly.artifact.DefaultDependencyResolver.resolveTransitively(DefaultDependencyResolver.java:253)
      	at org.apache.maven.plugin.assembly.artifact.DefaultDependencyResolver.resolveDependencySets(DefaultDependencyResolver.java:169)
      	at org.apache.maven.plugin.assembly.archive.phase.DependencySetAssemblyPhase.execute(DependencySetAssemblyPhase.java:94)
      	at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:178)
      	at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:484)
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
      	... 12 more
      [ERROR] 
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR] 
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
      

      There seems to be concurrent system property removal while properties.internal.SystemProperties is iterating over the previously calculated property keys:

          /**
           * Thread-safe System.properties copy implementation.
           *
           * @see "https://issues.apache.org/jira/browse/MNG-5670"
           */
          public static void addSystemProperties( Properties props )
          {
              for ( String key : System.getProperties().stringPropertyNames() )
              {
                  props.put( key, System.getProperty( key ) );
              }
      }
      

      System.getProperty( key ) possibly yields a null value which Hashtable/Properties does not accept.

      Possible solutions:

      • refrain from adding null by explicitly checking for it
      • replace for-loop with props.addAll(System.getProperties().clone())

      Attachments

        Issue Links

          Activity

            People

              gboue Guillaume Boué
              famod Falko Modler
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: