aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-03-12 19:27:57 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2016-03-12 19:27:57 -0500
commitea95bdeb62a44d12faee0a6fcabc121d45b9b0b8 (patch)
tree295936b4e2dc0a953fd4d01dc8f2a1f623f8ea7a
parentd13f028ae0e9e25c36971f8045f1d19cb3e94002 (diff)
downloadcbt-ea95bdeb62a44d12faee0a6fcabc121d45b9b0b8.tar.gz
cbt-ea95bdeb62a44d12faee0a6fcabc121d45b9b0b8.tar.bz2
cbt-ea95bdeb62a44d12faee0a6fcabc121d45b9b0b8.zip
Always reset security manager to what it was during startup. Should be less fragile with regards to concurrency and user code setting security managers.
-rw-r--r--nailgun_launcher/NailgunLauncher.java2
-rw-r--r--stage1/Stage1Lib.scala3
2 files changed, 3 insertions, 2 deletions
diff --git a/nailgun_launcher/NailgunLauncher.java b/nailgun_launcher/NailgunLauncher.java
index 78da041..11a8680 100644
--- a/nailgun_launcher/NailgunLauncher.java
+++ b/nailgun_launcher/NailgunLauncher.java
@@ -24,6 +24,8 @@ public class NailgunLauncher{
public static ConcurrentHashMap<String,ClassLoader> classLoaderCache =
new ConcurrentHashMap<String,ClassLoader>();
+ public static SecurityManager defaultSecurityManager = System.getSecurityManager();
+
public static void main(String[] args) throws ClassNotFoundException,
NoSuchMethodException,
IllegalAccessException,
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala
index 4af486c..9a1adb5 100644
--- a/stage1/Stage1Lib.scala
+++ b/stage1/Stage1Lib.scala
@@ -217,7 +217,6 @@ class Stage1Lib( val logger: Logger ) extends BaseLib{
}
def trapExitCode( code: => Unit ): ExitCode = {
- val old: Option[SecurityManager] = Option(System.getSecurityManager())
try{
System.setSecurityManager( trapSecurityManager )
code
@@ -226,7 +225,7 @@ class Stage1Lib( val logger: Logger ) extends BaseLib{
case TrappedExitCode(exitCode) =>
exitCode
} finally {
- System.setSecurityManager(old.getOrElse(null))
+ System.setSecurityManager(NailgunLauncher.defaultSecurityManager)
}
}
}