Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] openapi-generator-maven-plugin is not marked as threadSafe #5862

Closed
famod opened this issue Apr 8, 2020 · 4 comments · Fixed by #5898
Closed

[BUG] openapi-generator-maven-plugin is not marked as threadSafe #5862

famod opened this issue Apr 8, 2020 · 4 comments · Fixed by #5898

Comments

@famod
Copy link
Contributor

famod commented Apr 8, 2020

Description

Building a Maven multimodule project in parallel (e.g. mvn -T2 ...) that uses openapi-generator-maven-plugin yields the following warning for each plugin execution:

[2020-04-08T13:59:47.119Z] [WARNING] *****************************************************************
[2020-04-08T13:59:47.119Z] [WARNING] * Your build is requesting parallel execution, but project      *
[2020-04-08T13:59:47.119Z] [WARNING] * contains the following plugin(s) that have goals not marked   *
[2020-04-08T13:59:47.119Z] [WARNING] * as @threadSafe to support parallel building.                  *
[2020-04-08T13:59:47.119Z] [WARNING] * While this /may/ work fine, please look for plugin updates    *
[2020-04-08T13:59:47.119Z] [WARNING] * and/or request plugins be made thread-safe.                   *
[2020-04-08T13:59:47.119Z] [WARNING] * If reporting an issue, report it against the plugin in        *
[2020-04-08T13:59:47.119Z] [WARNING] * question, not against maven-core                              *
[2020-04-08T13:59:47.119Z] [WARNING] *****************************************************************
[2020-04-08T13:59:47.119Z] [WARNING] The following plugins are not marked @threadSafe in some-module:
[2020-04-08T13:59:47.119Z] [WARNING] org.openapitools:openapi-generator-maven-plugin:4.2.3
[2020-04-08T13:59:47.119Z] [WARNING] Enable debug to see more precisely which goals are not marked @threadSafe.
[2020-04-08T13:59:47.119Z] [WARNING] *****************************************************************
openapi-generator version

4.2.3

OpenAPI declaration file content or url

not relevant

Command line used for generation

mvn clean install -T2 (example)

Steps to reproduce

Build a multimodule project taht is using openapi-generator-maven-plugin in parallel.

Related issues/PRs

n/a

Suggest a fix

Add threadSafe=true to @Mojo: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java#L73
This assumes that the plugin does handle concurrent invocations (form different modules) without concurrency issues!

@famod
Copy link
Contributor Author

famod commented Apr 8, 2020

I was torn between bug and "improvement" so feel free to change the issue type.

@wing328
Copy link
Member

wing328 commented Apr 8, 2020

@famod I wonder if you can file a PR with the suggested fix when you've time.

@famod
Copy link
Contributor Author

famod commented Apr 8, 2020

@wing328 I'll gladly do that but is the plugin thread safe after all? I cannot answer this question.

@famod
Copy link
Contributor Author

famod commented Apr 8, 2020

By coincidence, we've just hit a sproadic build problem which might be a concurrency issue:

15:55:54  [INFO] --- openapi-generator-maven-plugin:4.2.3:generate (generate-code) @ module-A ---
15:55:54  [INFO] Execution of maven-enforcer-plugin:1.4.1:enforce (enforce-deps) @ module-B took 0.069s
15:55:54  [INFO] 
15:55:54  [INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-infix) @ module-B ---
15:55:54  [INFO] Execution of maven-enforcer-plugin:1.4.1:enforce (enforce-infix) @ module-B took 0.001s
15:55:54  [INFO] 
15:55:54  [INFO] --- maven-resources-plugin:3.1.0:resources (resources) @ module-B ---
15:55:54  [INFO] Using 'UTF-8' encoding to copy filtered resources.
15:55:54  [INFO] Copying 1 resource
15:55:54  [INFO] Copying 1 resource
15:55:54  [INFO] Execution of maven-resources-plugin:3.1.0:resources (resources) @ module-B took 0.005s
15:55:54  [INFO] 
15:55:54  [INFO] --- openapi-generator-maven-plugin:4.2.3:generate (generate-code) @ module-B ---
15:55:54  [ERROR] Cannot find a deserializer for non-concrete Map type [map type; class com.google.common.collect.ImmutableMap, [simple type, class java.lang.String] -> [simple type, class java.lang.String]]
15:55:54   at [Source: (File); line: 1, column: 1]
15:55:54  [ERROR] /opt/jenkins/data/jobs/th360-middleware-pr-pipelines-develop/jobs/PR-00048-THMED-2681-exception-handling/workspace/user/api/pro-fe/target/classes/api.json [0:0]: unexpected error in Open-API generation
15:55:54  java.lang.RuntimeException: Unable to deserialize config file: /opt/jenkins/data/jobs/th360-middleware-pr-pipelines-develop/jobs/PR-00048-THMED-2681-exception-handling/workspace/shared/rest/src/main/openapi/generator/import-mappings.json
15:55:54      at org.openapitools.codegen.config.CodegenConfigurator.fromFile (CodegenConfigurator.java:139)
15:55:54      at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:456)
15:55:54      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
15:55:54      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
15:55:54      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
15:55:54      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
15:55:54      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
15:55:54      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
15:55:54      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
15:55:54      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
15:55:54      at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515)
15:55:54      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
15:55:54      at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
15:55:54      at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
15:55:54      at java.lang.Thread.run (Thread.java:834)
15:55:54  [ERROR] 
15:55:54  java.lang.RuntimeException: Unable to deserialize config file: /opt/jenkins/data/jobs/th360-middleware-pr-pipelines-develop/jobs/PR-00048-THMED-2681-exception-handling/workspace/shared/rest/src/main/openapi/generator/import-mappings.json
15:55:54      at org.openapitools.codegen.config.CodegenConfigurator.fromFile (CodegenConfigurator.java:139)
15:55:54      at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:456)
15:55:54      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
15:55:54      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
15:55:54      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
15:55:54      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
15:55:54      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
15:55:54      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
15:55:54      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
15:55:54      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
15:55:54      at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515)
15:55:54      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
15:55:54      at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
15:55:54      at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
15:55:54      at java.lang.Thread.run (Thread.java:834)

You can see that module-A starts generating shortly before module-B and then module-B fails (before module-A has finished).

WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants