Skip to content

Commit 08a0f2e

Browse files
committed
refs #6260 - Fix #6260 on 3.0.0 by preventing parallelism
1 parent 2bb0604 commit 08a0f2e

File tree

1 file changed

+12
-5
lines changed
  • modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/v3/maven/plugin

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
/*
44
* Copyright 2001-2005 The Apache Software Foundation.
5-
*
5+
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
77
* in compliance with the License. You may obtain a copy of the License at
8-
*
8+
*
99
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
10+
*
1111
* Unless required by applicable law or agreed to in writing, software distributed under the License
1212
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1313
* or implied. See the License for the specific language governing permissions and limitations under
@@ -52,7 +52,7 @@
5252
/**
5353
* Goal which generates client/server code from a swagger json/yaml definition.
5454
*/
55-
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
55+
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
5656
public class CodeGenMojo extends AbstractMojo {
5757

5858
@Parameter(name = "verbose", required = false, defaultValue = "false")
@@ -220,7 +220,7 @@ public class CodeGenMojo extends AbstractMojo {
220220
* A map of reserved names and how they should be escaped
221221
*/
222222
@Parameter(name = "reservedWordsMappings")
223-
private List<String> reservedWordsMappings;
223+
private List<String> reservedWordsMappings;
224224

225225
/**
226226
* Generate the apis
@@ -314,6 +314,13 @@ public class CodeGenMojo extends AbstractMojo {
314314

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

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

0 commit comments

Comments
 (0)