Skip to content

Commit

Permalink
[FIXED JENKINS-31614] Avoid acquiring the Queue lock while holding ot…
Browse files Browse the repository at this point in the history
…her locks.

Originally-Committed-As: c89a054375f4e58947e9926d0be74abc5174a478
  • Loading branch information
jglick committed Jan 5, 2016
1 parent 757b7e2 commit ff9a05c
Showing 1 changed file with 11 additions and 7 deletions.
Expand Up @@ -38,15 +38,19 @@
* @author Kohsuke Kawaguchi
*/
public abstract class TryRepeatedly<V> extends AbstractFuture<V> {
private final int seconds;
private final int delay;
private ScheduledFuture<?> next;

protected TryRepeatedly(int seconds) {
this.seconds = seconds;
tryLater();
protected TryRepeatedly(int delay) {
this(delay, delay);
}

private void tryLater() {
protected TryRepeatedly(int delay, int initialDelay) {
this.delay = delay;
tryLater(initialDelay);
}

private void tryLater(int currentDelay) {
// TODO log a warning if trying for too long; probably Pickle.rehydrate should be given a TaskListener to note progress

if (isCancelled()) return;
Expand All @@ -57,14 +61,14 @@ public void run() {
try {
V v = tryResolve();
if (v == null)
tryLater();
tryLater(delay);
else
set(v);
} catch (Throwable t) {
setException(t);
}
}
}, seconds, TimeUnit.SECONDS);
}, currentDelay, TimeUnit.SECONDS);
}

@Override
Expand Down

0 comments on commit ff9a05c

Please sign in to comment.