Skip to content

Commit 9eb3224

Browse files
authored
Merge pull request #10329 from MosheElisha/master
Fix #6260 on master by preventing parallelism
2 parents 9e737b4 + 1b84ca1 commit 9eb3224

File tree

1 file changed

+8
-1
lines changed
  • modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin

1 file changed

+8
-1
lines changed

modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
/**
5151
* Goal which generates client/server code from a swagger json/yaml definition.
5252
*/
53-
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
53+
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
5454
public class CodeGenMojo extends AbstractMojo {
5555

5656
@Parameter(name = "verbose", required = false, defaultValue = "false")
@@ -315,6 +315,13 @@ public class CodeGenMojo extends AbstractMojo {
315315

316316
@Override
317317
public void execute() throws MojoExecutionException {
318+
// Using the naive approach for achieving thread safety
319+
synchronized (CodeGenMojo.class) {
320+
execute_();
321+
}
322+
}
323+
324+
protected void execute_() throws MojoExecutionException {
318325

319326
if (skip) {
320327
getLog().info("Code generation is skipped.");

0 commit comments

Comments
 (0)