diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index 08864961ebd9c0f6d5cde2b5f29d208bbbd4ff03..df9fb9714e2fac1d1946578f4f66216479e174cf 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -205,7 +205,14 @@ public class Executor extends Thread implements ModelObject { } 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 = @@ -213,7 +220,7 @@ public class Executor extends Thread implements ModelObject { return r; } finally { - lock.readLock().unlock(); + lock.writeLock().unlock(); } }