Skip to content

Commit 7eaf89c

Browse files
authored
Merge pull request #1062 from Vlatombe/thread-name-lock
Add debug information on which run we're locking on.
2 parents f547819 + 6a9d223 commit 7eaf89c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import org.jenkinsci.plugins.workflow.steps.StepExecution;
7171
import org.jenkinsci.plugins.workflow.support.concurrent.Futures;
7272
import org.jenkinsci.plugins.workflow.support.concurrent.Timeout;
73+
import org.jenkinsci.plugins.workflow.support.concurrent.WithThreadName;
7374
import org.jenkinsci.plugins.workflow.support.pickles.serialization.PickleResolver;
7475
import org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReader;
7576
import org.jenkinsci.plugins.workflow.support.storage.FlowNodeStorage;
@@ -1990,17 +1991,21 @@ private interface RunnableWithEx<E extends Exception> {
19901991
}
19911992

19921993
private <T, E extends Exception> T withReadLock(@NonNull SupplierWithEx<T, E> supplier) throws E {
1993-
readWriteLock.readLock().lock();
1994-
try {
1994+
try (var ignored = new WithThreadName(" acquiring read lock on storage of " + CpsFlowExecution.this)) {
1995+
readWriteLock.readLock().lock();
1996+
}
1997+
try (var ignored = new WithThreadName(" with read lock on storage of " + CpsFlowExecution.this)) {
19951998
return supplier.get();
19961999
} finally {
19972000
readWriteLock.readLock().unlock();
19982001
}
19992002
}
20002003

20012004
private <E extends Exception> void withWriteLock(@NonNull RunnableWithEx<E> runnable) throws E {
2002-
readWriteLock.writeLock().lock();
2003-
try {
2005+
try (var ignored = new WithThreadName(" acquiring write lock on storage of " + CpsFlowExecution.this)) {
2006+
readWriteLock.writeLock().lock();
2007+
}
2008+
try (var ignored = new WithThreadName(" with write lock on storage of " + CpsFlowExecution.this)) {
20042009
runnable.run();
20052010
} finally {
20062011
readWriteLock.writeLock().unlock();

0 commit comments

Comments
 (0)