Skip to content

Commit

Permalink
[FIXED JENKINS-4220] fixed a dead lock.
Browse files Browse the repository at this point in the history
While the original report is in https://cloudbees.zendesk.com/tickets/427, this fix also takes care of JENKINS-4220.

Originally-Committed-As: 53a31c31530166fc7a53900b58127c002a7e8cda
  • Loading branch information
kohsuke committed Mar 1, 2011
1 parent 36c11f5 commit a901e3d
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 @@ -126,6 +126,8 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven

private String mavenVersionUsed;

private transient Object notifyModuleBuildLock = new Object();

public MavenModuleSetBuild(MavenModuleSet job) throws IOException {
super(job);
}
Expand All @@ -134,6 +136,12 @@ public MavenModuleSetBuild(MavenModuleSet project, File buildDir) throws IOExcep
super(project, buildDir);
}

@Override
protected void onLoad() {
super.onLoad();
notifyModuleBuildLock = new Object();
}

/**
* Exposes {@code MAVEN_OPTS} to forked processes.
*
Expand Down Expand Up @@ -457,7 +465,9 @@ public Fingerprint.RangeSet getDownstreamRelationship(AbstractProject that) {

// actions need to be replaced atomically especially
// given that two builds might complete simultaneously.
synchronized(this) {
// 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) {
boolean modified = false;

List<Action> actions = getActions();
Expand Down Expand Up @@ -1318,7 +1328,7 @@ private String getRootPath(String prefix) {
* Extra verbose debug switch.
*/
public static boolean debug = Boolean.getBoolean( "hudson.maven.debug" );

@Override
public MavenModuleSet getParent() {// don't know why, but javac wants this
return super.getParent();
Expand Down

0 comments on commit a901e3d

Please sign in to comment.