license-maven-plugin icon indicating copy to clipboard operation
license-maven-plugin copied to clipboard

aggregate-add-third-party not threadsafe

Open davidkarlsen opened this issue 7 years ago • 6 comments

The aggregate-add-third-party is not threadsafe, and forces me to run builds with --builder singlethreaded which is no fun. Could it be made threadsafe?

http://www.mojohaus.org/license-maven-plugin/aggregate-add-third-party-mojo.html

davidkarlsen avatar May 10 '17 08:05 davidkarlsen

@davidkarlsen , I just make it so. I just deployed a snapshot can you test it please ? thanks.

tchemit avatar Jun 30 '17 11:06 tchemit

It's more that I got a concurrentModificationException AFAIR - not simply the flag.

davidkarlsen avatar Aug 18 '17 19:08 davidkarlsen

I get this:

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)                          
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)                          
        at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:353)          
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198)                          
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)                          
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)                          
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) 
        at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:200)                                                                                                          
        at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:196)                                                                                                          
        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:1149)                          
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)                          
        at java.lang.Thread.run(Thread.java:748)          
Caused by: org.apache.maven.plugin.MojoExecutionException: could not execute goal AddThirdPartyMojo for reason : Could not create directory /Users/et2448/projects/tac/jfr/tac-jfr-server/jfr-srv-schemas/target/generated-sources/license                                                         
        at org.codehaus.mojo.license.AbstractLicenseMojo.execute(AbstractLicenseMojo.java:215)                      
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)        
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)                          
        ... 15 more                                       
Caused by: java.io.IOException: Could not create directory /Users/et2448/projects/tac/jfr/tac-jfr-server/jfr-srv-schemas/target/generated-sources/license                                                                                
        at org.codehaus.mojo.license.utils.FileUtil.createDirectoryIfNecessary(FileUtil.java:105)                   
        at org.codehaus.mojo.license.utils.FileUtil.printString(FileUtil.java:254)                                  
        at org.codehaus.mojo.license.api.DefaultThirdPartyTool.writeThirdPartyFile(DefaultThirdPartyTool.java:663)  
        at org.codehaus.mojo.license.AbstractAddThirdPartyMojo.writeThirdPartyFile(AbstractAddThirdPartyMojo.java:701)                                                                                                                   
        at org.codehaus.mojo.license.AddThirdPartyMojo.doAction(AddThirdPartyMojo.java:240)                         
        at org.codehaus.mojo.license.AbstractLicenseMojo.execute(AbstractLicenseMojo.java:202)                 

which I do not get if I run --builder singlethreaded

the only change is:

diff --git a/pom.xml b/pom.xml
index 484c7a6..15afa99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -354,6 +354,18 @@
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>buildnumber-maven-plugin</artifactId>
                        </plugin>
+                 <plugin>
+                         <groupId>org.codehaus.mojo</groupId>
+                         <artifactId>license-maven-plugin</artifactId>
+                         <version>1.12</version>
+                         <executions>
+                                 <execution>
+                                         <goals>
+                                                 <goal>aggregate-add-third-party</goal>
+                                         </goals>
+                                 </execution>
+                         </executions>
+                 </plugin>
                </plugins>
        </build>

haven't dug into the plugin code to see whats going on.

davidkarlsen avatar Aug 18 '17 19:08 davidkarlsen

Yes, also with 1.15-SNAPSHOT I will get "Could not create directory" at random modules if using multithreaded builder.

davidkarlsen avatar Aug 18 '17 20:08 davidkarlsen

Similarly the add-third-party is not thread safe.

@tchemit Could it be made thread-safe? Should I create a separate issue for that? Are there any changes needed to the plugin? I would be happy to contribute if you could point me in the right direction.

frant-hartm avatar Oct 12 '20 14:10 frant-hartm

We have same issue. maven-license-plugin 2.0.0 [2021-01-24T12:41:35.177Z] [ERROR] Failed to execute goal org.codehaus.mojo:license-maven-plugin:2.0.0:add-third-party (license-report) on project app-biggantt-lib: could not init goal AddThirdPartyMojo for reason : null: ConcurrentModificationException -> [Help 1] [2021-01-24T12:41:35.177Z] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:license-maven-plugin:2.0.0:add-third-party (license-report) on project app-biggantt-lib: could not init goal AddThirdPartyMojo for reason : null [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186) [2021-01-24T12:41:35.177Z] at java.util.concurrent.FutureTask.run (FutureTask.java:266) [2021-01-24T12:41:35.177Z] at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511) [2021-01-24T12:41:35.177Z] at java.util.concurrent.FutureTask.run (FutureTask.java:266) [2021-01-24T12:41:35.177Z] at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149) [2021-01-24T12:41:35.177Z] at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624) [2021-01-24T12:41:35.177Z] at java.lang.Thread.run (Thread.java:748) [2021-01-24T12:41:35.177Z] Caused by: org.apache.maven.plugin.MojoExecutionException: could not init goal AddThirdPartyMojo for reason : null [2021-01-24T12:41:35.177Z] at org.codehaus.mojo.license.AbstractLicenseMojo.execute (AbstractLicenseMojo.java:185) [2021-01-24T12:41:35.177Z] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186) [2021-01-24T12:41:35.177Z] at java.util.concurrent.FutureTask.run (FutureTask.java:266) [2021-01-24T12:41:35.177Z] at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511) [2021-01-24T12:41:35.177Z] at java.util.concurrent.FutureTask.run (FutureTask.java:266) [2021-01-24T12:41:35.177Z] at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149) [2021-01-24T12:41:35.177Z] at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624) [2021-01-24T12:41:35.177Z] at java.lang.Thread.run (Thread.java:748) [2021-01-24T12:41:35.177Z] Caused by: java.util.ConcurrentModificationException [2021-01-24T12:41:35.177Z] at java.util.TreeMap$PrivateEntryIterator.nextEntry (TreeMap.java:1211) [2021-01-24T12:41:35.177Z] at java.util.TreeMap$EntryIterator.next (TreeMap.java:1247) [2021-01-24T12:41:35.177Z] at java.util.TreeMap$EntryIterator.next (TreeMap.java:1242) [2021-01-24T12:41:35.177Z] at java.util.TreeMap.buildFromSorted (TreeMap.java:2559) [2021-01-24T12:41:35.177Z] at java.util.TreeMap.buildFromSorted (TreeMap.java:2508) [2021-01-24T12:41:35.177Z] at java.util.TreeMap.putAll (TreeMap.java:319) [2021-01-24T12:41:35.177Z] at org.codehaus.mojo.license.api.DependenciesTool.loadProjectDependencies (DependenciesTool.java:120) [2021-01-24T12:41:35.177Z] at org.codehaus.mojo.license.api.DefaultThirdPartyHelper.loadDependencies (DefaultThirdPartyHelper.java:152) [2021-01-24T12:41:35.177Z] at org.codehaus.mojo.license.AddThirdPartyMojo.loadDependencies (AddThirdPartyMojo.java:226) [2021-01-24T12:41:35.177Z] at org.codehaus.mojo.license.AbstractAddThirdPartyMojo.init (AbstractAddThirdPartyMojo.java:750) [2021-01-24T12:41:35.177Z] at org.codehaus.mojo.license.AbstractLicenseMojo.execute (AbstractLicenseMojo.java:171) [2021-01-24T12:41:35.177Z] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190) [2021-01-24T12:41:35.177Z] at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186) [2021-01-24T12:41:35.177Z] at java.util.concurrent.FutureTask.run (FutureTask.java:266) [2021-01-24T12:41:35.177Z] at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511) [2021-01-24T12:41:35.177Z] at java.util.concurrent.FutureTask.run (FutureTask.java:266) [2021-01-24T12:41:35.177Z] at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149) [2021-01-24T12:41:35.177Z] at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624) [2021-01-24T12:41:35.177Z] at java.lang.Thread.run (Thread.java:748) [2021-01-24T12:41:35.177Z] [ERROR] [2021-01-24T12:41:35.177Z] [ERROR] Re-run Maven using the -X switch to enable full debug logging.

bjanczak avatar Jan 27 '21 11:01 bjanczak