You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2021/06/17 16:36:47 UTC

[ant] branch master updated: Remove practically no-op code which was calling System.setSecurityManager()

This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new f61ac12  Remove practically no-op code which was calling System.setSecurityManager()
f61ac12 is described below

commit f61ac12960af852b8237fe91f256dea27d898dca
Author: Jaikiran Pai <ja...@apache.org>
AuthorDate: Thu Jun 17 08:51:21 2021 +0530

    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 41893fdb3052f79a2d09d7f8a86711912fc429e6) but that was then reverted in commit ff4e823ee29f5a6a0e1658ff8ff43f1076f7a559. So this current piece of code is practically doing nothing.
---
 src/main/org/apache/tools/ant/Main.java | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java
index 18feef8..bb07cab 100644
--- a/src/main/org/apache/tools/ant/Main.java
+++ b/src/main/org/apache/tools/ant/Main.java
@@ -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);