Skip to content

Commit

Permalink
Merge pull request #1730 from stephenc/jenkins-28690
Browse files Browse the repository at this point in the history
[FIXED JENKINS-28690] Deadlock in hudson.model.Executor
  • Loading branch information
stephenc committed Jun 10, 2015
2 parents f628e39 + ddb0a47 commit 4540ba7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/src/main/java/hudson/model/Executor.java
Expand Up @@ -205,15 +205,22 @@ private void interrupt(Result result, boolean forShutdown, CauseOfInterruption..
}

public Result abortResult() {
lock.readLock().lock();
// this method is almost always called as a result of the current thread being interrupted
// as a result we need to clean the interrupt flag so that the lock's lock method doesn't
// get confused and think it was interrupted while awaiting the lock
Thread.interrupted();
// we need to use a write lock as we may be repeatedly interrupted while processing and
// we need the same lock as used in void interrupt(Result,boolean,CauseOfInterruption...)
// JENKINS-28690
lock.writeLock().lock();
try {
Result r = interruptStatus;
if (r == null) r =
Result.ABORTED; // this is when we programmatically throw InterruptedException instead of calling the interrupt method.

return r;
} finally {
lock.readLock().unlock();
lock.writeLock().unlock();
}
}

Expand Down

0 comments on commit 4540ba7

Please sign in to comment.