Skip to content
Permalink
Browse files

[FIXED JENKINS-18895] MavenModuleSetBuild.getResult is expensive.

Originally-Committed-As: d1d524863cbb2f1f443fc4bf7c25933b7a31b85d
  • Loading branch information
jglick committed Jul 29, 2013
1 parent ca25b16 commit 5823a8991b968ad44c57dc40faab9c6c3b0db0fb
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/main/java/hudson/maven/MavenModuleSetBuild.java
@@ -53,7 +53,6 @@
import hudson.model.Run;
import hudson.model.StringParameterDefinition;
import hudson.model.TaskListener;
import hudson.remoting.Callable;
import hudson.remoting.VirtualChannel;
import hudson.scm.ChangeLogSet;
import hudson.tasks.BuildStep;
@@ -93,7 +92,6 @@
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.codehaus.plexus.util.PathTool;
@@ -136,6 +134,7 @@
private String mavenVersionUsed;

private transient Object notifyModuleBuildLock = new Object();
private transient Result effectiveResult;

public MavenModuleSetBuild(MavenModuleSet job) throws IOException {
super(job);
@@ -194,6 +193,11 @@ public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedE
*/
@Override
public Result getResult() {
synchronized (notifyModuleBuildLock) {
if (effectiveResult != null) {
return effectiveResult;
}
}
Result r = super.getResult();

for (MavenBuild b : getModuleLastBuilds().values()) {
@@ -208,6 +212,11 @@ public Result getResult() {
r = r.combine(br);
}

synchronized (notifyModuleBuildLock) {
if (effectiveResult == null) {
effectiveResult = r;
}
}
return r;
}

@@ -522,6 +531,7 @@ public void run() {
// use a separate lock object since this synchronized block calls into plugins,
// which in turn can access other MavenModuleSetBuild instances, which will result in a dead lock.
synchronized(notifyModuleBuildLock) {
effectiveResult = null;
boolean modified = false;

List<Action> actions = getActions();

0 comments on commit 5823a89

Please sign in to comment.