提交 1bc1d617 编写于 作者: S Stephen Connolly 提交者: GitHub

Merge pull request #2794 from stephenc/dont-wrap-interrupt

Don't wrap the InterruptedException without unwrapping
......@@ -32,6 +32,7 @@ import java.util.Iterator;
import java.util.concurrent.Callable;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.annotation.Nonnull;
import jenkins.security.NotReallyRoleSensitiveCallable;
/**
* Controls mutual exclusion of {@link ResourceList}.
......@@ -77,20 +78,18 @@ public class ResourceController {
*/
public void execute(@Nonnull Runnable task, final ResourceActivity activity ) throws InterruptedException {
final ResourceList resources = activity.getResourceList();
_withLock(new Runnable() {
_withLock(new NotReallyRoleSensitiveCallable<Void,InterruptedException>() {
@Override
public void run() {
while(inUse.isCollidingWith(resources))
try {
// TODO revalidate the resource list after re-acquiring lock, for now we just let the build fail
_await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
public Void call() throws InterruptedException {
while (inUse.isCollidingWith(resources)) {
// TODO revalidate the resource list after re-acquiring lock, for now we just let the build fail
_await();
}
// we have a go
inProgress.add(activity);
inUse = ResourceList.union(inUse,resources);
inUse = ResourceList.union(inUse, resources);
return null;
}
});
......@@ -184,5 +183,11 @@ public class ResourceController {
return callable.call();
}
}
protected <V, T extends Throwable> V _withLock(hudson.remoting.Callable<V,T> callable) throws T {
synchronized (this) {
return callable.call();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册