mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
[FIXED HUDSON-2230] Fixed IllegalMonitorStateException. In 1.249.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11604 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
fb6b85cf8b
commit
814cd5ba4b
1 file changed
+12
-8
@@ -24,6 +24,11 @@ import java.util.logging.Logger;
|
||||
public abstract class Build <P extends Project<P,B>,B extends Build<P,B>>
|
||||
extends AbstractBuild<P,B> {
|
||||
|
||||
/**
|
||||
* If the build required a lock, remember it so that we can release it.
|
||||
*/
|
||||
private transient ReentrantLock buildLock;
|
||||
|
||||
/**
|
||||
* Creates a new build.
|
||||
*/
|
||||
@@ -48,16 +53,16 @@ public abstract class Build <P extends Project<P,B>,B extends Build<P,B>>
|
||||
SCMTrigger t = (SCMTrigger)project.getTriggers().get(SCMTrigger.DESCRIPTOR);
|
||||
if(t!=null) {
|
||||
// acquire the lock
|
||||
ReentrantLock lock = t.getLock();
|
||||
synchronized(lock) {
|
||||
buildLock = t.getLock();
|
||||
synchronized(buildLock) {
|
||||
try {
|
||||
if(lock.isLocked()) {
|
||||
if(buildLock.isLocked()) {
|
||||
long time = System.currentTimeMillis();
|
||||
LOGGER.info("Waiting for the polling of "+getParent()+" to complete");
|
||||
lock.lockInterruptibly();
|
||||
buildLock.lockInterruptibly();
|
||||
LOGGER.info("Polling completed. Waited "+(System.currentTimeMillis()-time)+"ms");
|
||||
} else
|
||||
lock.lockInterruptibly();
|
||||
buildLock.lockInterruptibly();
|
||||
} catch (InterruptedException e) {
|
||||
// handle the interrupt later
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -69,9 +74,8 @@ public abstract class Build <P extends Project<P,B>,B extends Build<P,B>>
|
||||
@Override
|
||||
protected void onEndBuilding() {
|
||||
super.onEndBuilding();
|
||||
SCMTrigger t = (SCMTrigger)project.getTriggers().get(SCMTrigger.DESCRIPTOR);
|
||||
if(t!=null)
|
||||
t.getLock().unlock();
|
||||
if(buildLock!=null)
|
||||
buildLock.unlock();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user