Skip to content

Commit

Permalink
[FIXED JENKINS-18895] MavenModuleSetBuild.getResult is expensive.
Browse files Browse the repository at this point in the history
Originally-Committed-As: d1d524863cbb2f1f443fc4bf7c25933b7a31b85d
  • Loading branch information
jglick committed Jul 29, 2013
1 parent ca25b16 commit 5823a89
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/hudson/maven/MavenModuleSetBuild.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -136,6 +134,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
private String mavenVersionUsed;

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

public MavenModuleSetBuild(MavenModuleSet job) throws IOException {
super(job);
Expand Down Expand Up @@ -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()) {
Expand All @@ -208,6 +212,11 @@ public Result getResult() {
r = r.combine(br);
}

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

Expand Down Expand Up @@ -522,6 +531,7 @@ public Fingerprint.RangeSet getDownstreamRelationship(@SuppressWarnings("rawtype
// 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();
Expand Down

0 comments on commit 5823a89

Please sign in to comment.