Use PrivilegedExceptionAction to do privileged actions that might throw
an exception. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3856 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -29,6 +29,8 @@ import java.lang.reflect.Modifier;
|
|||||||
|
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
import java.security.PrivilegedActionException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -100,19 +102,19 @@ public class Streamer
|
|||||||
|
|
||||||
// create our streamer in a privileged block so that it can
|
// create our streamer in a privileged block so that it can
|
||||||
// introspect on the to be streamed class
|
// introspect on the to be streamed class
|
||||||
Object res = AccessController.doPrivileged(new PrivilegedAction() {
|
try {
|
||||||
public Object run () {
|
stream = (Streamer) AccessController.doPrivileged(
|
||||||
try {
|
new PrivilegedExceptionAction() {
|
||||||
return new Streamer(target);
|
public Object run ()
|
||||||
} catch (IOException ioe) {
|
throws IOException
|
||||||
return ioe;
|
{
|
||||||
}
|
return new Streamer(target);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (res instanceof IOException) {
|
} catch (PrivilegedActionException pae) {
|
||||||
throw (IOException)res;
|
throw (IOException) pae.getCause();
|
||||||
}
|
}
|
||||||
_streamers.put(target, stream = (Streamer)res);
|
_streamers.put(target, stream);
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user