jenkinsci/jenkins — pull request #699 by jglick (2013-02-08 19:25:32+00:00)
Title: NonSerializableSecurityContext, ACL.impersonate

Corrected a misspelled class name; and introduced a new overload of `impersonate` that does not make you remember to use a `finally`-block. Considered having it take `java.util.concurrent.Callable` but this throws `Exception` which is inconvenient; ` … hudson.remoting.Callable` lets that be parameterized but I settled on simple `Runnable` by comparing the following JDK 8 λ snippets:

```
ACL.impersonate(ACL.SYSTEM, () -> {
killEmAll();
return null;
});
```

vs. the more readable and natural

```
ACL.impersonate(ACL.SYSTEM, () -> killEmAll());
```

(I remember seeing some proposal for `java.lang.Nothing` that would be better than `Void` for this case, but cannot find it now. Cannot find anything more suitable in `java.util.function.*` either, and anyway we could not yet include such types in the signature.)