Skip to content

Commit

Permalink
Default the number of threads to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Dec 5, 2022
1 parent 046a0f9 commit 0ceb5b1
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
@Named
@Singleton
public class DefaultProjectBuilder implements ProjectBuilder {
private static final String BUILDER_PARALLELISM = "maven.projectBuilder.parallelism";
public static final String BUILDER_PARALLELISM = "maven.projectBuilder.parallelism";
public static final int DEFAULT_BUILDER_PARALLELISM = 4;

private final Logger logger = LoggerFactory.getLogger(getClass());
private final ModelBuilder modelBuilder;
Expand Down Expand Up @@ -221,7 +222,7 @@ class BuildSession {
}

private int getParallelism(ProjectBuildingRequest request) {
int parallelism = Runtime.getRuntime().availableProcessors();
int parallelism = DEFAULT_BUILDER_PARALLELISM;
try {
String str = request.getUserProperties().getProperty(BUILDER_PARALLELISM);
if (str == null) {
Expand All @@ -233,7 +234,7 @@ private int getParallelism(ProjectBuildingRequest request) {
} catch (Exception e) {
// ignore
}
return parallelism;
return Math.min(Runtime.getRuntime().availableProcessors(), parallelism);
}

ProjectBuildingResult build(File pomFile, ModelSource modelSource) throws ProjectBuildingException {
Expand Down

0 comments on commit 0ceb5b1

Please sign in to comment.