You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by ro...@apache.org on 2016/07/13 21:11:38 UTC

oozie git commit: OOZIE-2581 Oozie should reset SecurityManager in finally block (satishsaley via rohini)

Repository: oozie
Updated Branches:
  refs/heads/master 1cb23a554 -> aa6e2eb44


OOZIE-2581 Oozie should reset SecurityManager in finally block (satishsaley via rohini)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/aa6e2eb4
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/aa6e2eb4
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/aa6e2eb4

Branch: refs/heads/master
Commit: aa6e2eb44c20b153de27afa60f91e8f765bc09a2
Parents: 1cb23a5
Author: Rohini Palaniswamy <ro...@apache.org>
Authored: Wed Jul 13 14:11:32 2016 -0700
Committer: Rohini Palaniswamy <ro...@apache.org>
Committed: Wed Jul 13 14:11:32 2016 -0700

----------------------------------------------------------------------
 release-log.txt                                 |  1 +
 .../oozie/action/hadoop/LauncherMapper.java     | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/aa6e2eb4/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 2036dbc..686378c 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 4.3.0 release (trunk - unreleased)
 
+OOZIE-2581 Oozie should reset SecurityManager in finally block (satishsaley via rohini)
 OOZIE-2579 Bulk kill tests in TestBulkWorkflowXCommand might fail because of a race condition (pbacsko via rkanter)
 OOZIE-2587 Disable SchedulerService on certain tests (pbacsko via rkanter)
 OOZIE-2603 Give thread pools a meaningful name in CallableQueueService and SchedulerService (pbacsko via rkanter)

http://git-wip-us.apache.org/repos/asf/oozie/blob/aa6e2eb4/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
----------------------------------------------------------------------
diff --git a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
index 545f8e2..17ba97d 100644
--- a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
+++ b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
@@ -28,8 +28,6 @@ import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.security.Permission;
@@ -150,6 +148,7 @@ public class LauncherMapper<K1, V1, K2, V2> implements Mapper<K1, V1, K2, V2>, R
 
     @Override
     public void map(K1 key, V1 value, OutputCollector<K2, V2> collector, Reporter reporter) throws IOException {
+        SecurityManager initialSecurityManager = System.getSecurityManager();
         try {
             if (configFailure) {
                 throw configureFailureEx;
@@ -163,7 +162,6 @@ public class LauncherMapper<K1, V1, K2, V2> implements Mapper<K1, V1, K2, V2>, R
                 int errorCode = 0;
                 Throwable errorCause = null;
                 String errorMessage = null;
-
                 try {
                     new LauncherSecurityManager();
                 }
@@ -321,6 +319,7 @@ public class LauncherMapper<K1, V1, K2, V2> implements Mapper<K1, V1, K2, V2>, R
         }
         finally {
             uploadActionDataToHDFS();
+            resetSecurityManager(initialSecurityManager);
         }
     }
 
@@ -601,6 +600,19 @@ public class LauncherMapper<K1, V1, K2, V2> implements Mapper<K1, V1, K2, V2>, R
         }
     }
 
+    private void resetSecurityManager(SecurityManager initialSecurityManager) {
+        try {
+            SecurityManager prev = System.getSecurityManager();
+            System.setSecurityManager(initialSecurityManager);
+            System.out
+                    .println("Successfully reset security manager from " + prev + " to " + System.getSecurityManager());
+        }
+        catch (Throwable t) {
+            System.err.println("Failed to reset security manager: " + t.getMessage());
+            t.printStackTrace(System.err);
+        }
+    }
+
 }
 
 class LauncherSecurityManager extends SecurityManager {
@@ -659,4 +671,4 @@ class JavaMainException extends Exception {
     public JavaMainException(Throwable t) {
         super(t);
     }
-}
+}
\ No newline at end of file