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.
  • Loading branch information
kohsuke committed Mar 1, 2011
1 parent 584112a commit 53a31c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -61,6 +61,9 @@
<li class=bug>
Environment variable not available for Maven build/POM parsing.
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-8865">issue 8865</a>)
<li class=bug>
Fixed a dead lock in concurrent builds of the same Maven projects.
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-4220">issue 4220</a>)
<li class=rfe>
thread dump now reports all the threads from all the slaves, not just the master.
<li class=bug>
Expand Down
14 changes: 12 additions & 2 deletions maven-plugin/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 53a31c3

Please sign in to comment.