Skip to content

Commit

Permalink
Disable security manager in Nailgun
Browse files Browse the repository at this point in the history
The security manager installed by Nailgun seems to add a noticeable
overhead in IO operations.  facebookarchive#134

As a result, we don't install a security manager. Nailgun only uses it
to trap exit, and in our case we don't need to do that since Bloop
doesn't define any `nailShutdown`.
  • Loading branch information
jvican committed Apr 13, 2018
1 parent 615737a commit 5260960
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
*/
package com.martiansoftware.nailgun;

import com.martiansoftware.nailgun.builtins.DefaultNail;
import com.sun.jna.Platform;

import java.io.InputStream;
import java.io.PrintStream;
import java.net.InetAddress;
Expand All @@ -27,9 +30,6 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import com.martiansoftware.nailgun.builtins.DefaultNail;
import com.sun.jna.Platform;

/**
* <p>Listens for new connections from NailGun clients and launches NGSession
* threads to process them.</p>
Expand Down Expand Up @@ -329,7 +329,8 @@ public void shutdown(boolean exitVM) {
System.setOut(out);
System.setErr(err);

System.setSecurityManager(originalSecurityManager);
// Security manager is always disabled
//System.setSecurityManager(originalSecurityManager);

if (exitVM) {
System.exit(0);
Expand Down Expand Up @@ -363,10 +364,11 @@ public void run() {
NGSession sessionOnDeck = null;

originalSecurityManager = System.getSecurityManager();
System.setSecurityManager(
new NGSecurityManager(
originalSecurityManager));

// Remove overhead of security manager https://github.com/facebook/nailgun/issues/134
//System.setSecurityManager(
// new NGSecurityManager(
// originalSecurityManager));

synchronized (System.in) {
if (!(System.in instanceof ThreadLocalInputStream)) {
Expand Down

0 comments on commit 5260960

Please sign in to comment.