From 174fa1b9c6075a069c16694213a049d192975d29 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 15 Feb 2006 04:04:24 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/io/Streamer.java | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/java/com/threerings/io/Streamer.java b/src/java/com/threerings/io/Streamer.java index 3be335f46..8374331a5 100644 --- a/src/java/com/threerings/io/Streamer.java +++ b/src/java/com/threerings/io/Streamer.java @@ -29,6 +29,8 @@ import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; import java.io.IOException; import java.util.ArrayList; @@ -100,19 +102,19 @@ public class Streamer // create our streamer in a privileged block so that it can // introspect on the to be streamed class - Object res = AccessController.doPrivileged(new PrivilegedAction() { - public Object run () { - try { - return new Streamer(target); - } catch (IOException ioe) { - return ioe; - } - } - }); - if (res instanceof IOException) { - throw (IOException)res; + try { + stream = (Streamer) AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Object run () + throws IOException + { + return new Streamer(target); + } + }); + } catch (PrivilegedActionException pae) { + throw (IOException) pae.getCause(); } - _streamers.put(target, stream = (Streamer)res); + _streamers.put(target, stream); } return stream; }