Browse Source

Remove practically no-op code which was calling System.setSecurityManager()

Starting Java 17, System.setSecurityManager() usage is deprecated (for removal) as noted in https://openjdk.java.net/jeps/411.
The code here was just calling getSecurityManager() and then in a finally block setting it back using setSecurityManager(). However, we aren't setting any other security manager in between these calls.
Looking at the code history, it appears that at one point back in 2001, we were indeed setting a custom security manager (commit 41893fdb30) but that was then reverted in commit ff4e823ee2. So this current piece of code is practically doing nothing.
master
Jaikiran Pai 4 years ago
parent
commit
f61ac12960
1 changed files with 0 additions and 15 deletions
  1. +0
    -15
      src/main/org/apache/tools/ant/Main.java

+ 0
- 15
src/main/org/apache/tools/ant/Main.java View File

@@ -749,15 +749,6 @@ public class Main implements AntMain {
final PrintStream savedErr = System.err;
final PrintStream savedOut = System.out;
final InputStream savedIn = System.in;

// use a system manager that prevents from System.exit()
SecurityManager oldsm = null;
oldsm = System.getSecurityManager();

//SecurityManager can not be installed here for backwards
//compatibility reasons (PD). Needs to be loaded prior to
//ant class if we are going to implement it.
//System.setSecurityManager(new NoExitSecurityManager());
try {
if (allowInput) {
project.setDefaultInputStream(System.in);
@@ -826,12 +817,6 @@ public class Main implements AntMain {

project.executeTargets(targets);
} finally {
// put back the original security manager
//The following will never eval to true. (PD)
if (oldsm != null) {
System.setSecurityManager(oldsm);
}

System.setOut(savedOut);
System.setErr(savedErr);
System.setIn(savedIn);


Loading…
Cancel
Save