Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

delete NGSecurityManager #204

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@

package com.facebook.nailgun.examples;

import com.facebook.nailgun.NGContext;

/** Finish nail with provided exit code */
public class Exit {

public static void main(String[] args) {
public static void nailMain(NGContext context) {

int exitCode = (int) ((Math.random() * 1000) + 1);
if (args.length > 0) {
if (context.getArgs().length > 0) {
try {
exitCode = Integer.parseInt(args[0]);
exitCode = Integer.parseInt(context.getArgs()[0]);
} catch (Exception e) {
}
}
// Close stdout to test the exit code is returned properly
// even in such case
System.out.close();
System.exit(exitCode);
context.exit(exitCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static void nailMain(final NGContext context) {
}
}
} catch (InterruptedException ignored) {
System.exit(42);
context.exit(42);
}
System.exit(0);
context.exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public NamedThreadFactory(String threadName) {

@Override
public Thread newThread(Runnable r) {
SecurityManager s = System.getSecurityManager();
ThreadGroup group =
(s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
ThreadGroup group = Thread.currentThread().getThreadGroup();
Thread t = new Thread(group, r, this.threadName, 0);
if (t.isDaemon()) {
t.setDaemon(false);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ public class NGServer implements Runnable {
/** a collection of all classes executed by this server so far */
private final Map<String, NailStats> allNailStats;

/** Remember the security manager we start with so we can restore it later */
private SecurityManager originalSecurityManager = null;

private final int heartbeatTimeoutMillis;

/**
Expand Down Expand Up @@ -314,9 +311,6 @@ public int getPort() {

/** Listens for new connections and launches NGSession threads to process them. */
public void run() {
originalSecurityManager = System.getSecurityManager();
System.setSecurityManager(new NGSecurityManager(originalSecurityManager));

if (!(System.in instanceof ThreadLocalInputStream)) {
System.setIn(new ThreadLocalInputStream(in));
}
Expand Down Expand Up @@ -409,8 +403,6 @@ public void run() {
System.setOut(out);
System.setErr(err);

System.setSecurityManager(originalSecurityManager);

running.set(false);
}

Expand Down