You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2025/05/13 19:02:50 UTC
(hadoop) branch trunk updated: HADOOP-19526. Skip tests in Hadoop common that depend on SecurityManager if the JVM does not support it
This is an automated email from the ASF dual-hosted git repository.
cnauroth pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9c05d9667bc HADOOP-19526. Skip tests in Hadoop common that depend on SecurityManager if the JVM does not support it
9c05d9667bc is described below
commit 9c05d9667bcb1eb5f0fcaaa25a4a5b70e01ead65
Author: Istvan Toth <st...@apache.org>
AuthorDate: Tue May 13 18:09:14 2025 +0000
HADOOP-19526. Skip tests in Hadoop common that depend on SecurityManager if the JVM does not support it
Closes #7567
Signed-off-by: Chris Nauroth <cn...@apache.org>
Reviewed-by: He Xiaoqiao <he...@apache.org>
---
.../main/java/org/apache/hadoop/tools/DistCp.java | 3 +-
.../org/apache/hadoop/tools/TestExternalCall.java | 45 +++++-----------------
.../mapred/gridmix/TestGridmixSubmission.java | 3 --
3 files changed, 12 insertions(+), 39 deletions(-)
diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java
index cba47545797..6b7db0c2d72 100644
--- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java
+++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.util.Random;
+import org.apache.hadoop.util.ExitUtil;
import org.apache.hadoop.util.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -471,7 +472,7 @@ public static void main(String argv[]) {
LOG.error("Couldn't complete DistCp operation: ", e);
exitCode = DistCpConstants.UNKNOWN_ERROR;
}
- System.exit(exitCode);
+ ExitUtil.terminate(exitCode);
}
/**
diff --git a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestExternalCall.java b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestExternalCall.java
index c50b1974f38..73e826445b1 100644
--- a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestExternalCall.java
+++ b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestExternalCall.java
@@ -27,13 +27,13 @@
import org.apache.hadoop.mapreduce.Cluster;
import org.apache.hadoop.mapreduce.JobSubmissionFiles;
import org.apache.hadoop.tools.util.TestDistCpUtils;
+import org.apache.hadoop.util.ExitUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.OutputStream;
-import java.security.Permission;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -64,9 +64,11 @@ private static Configuration getConf() {
@BeforeEach
public void setup() {
+ ExitUtil.disableSystemExit();
+ ExitUtil.disableSystemHalt();
+ ExitUtil.resetFirstExitException();
+ ExitUtil.resetFirstHaltException();
- securityManager = System.getSecurityManager();
- System.setSecurityManager(new NoExitSecurityManager());
try {
fs = FileSystem.get(getConf());
root = new Path("target/tmp").makeQualified(fs.getUri(),
@@ -79,10 +81,12 @@ public void setup() {
@AfterEach
public void tearDown() {
- System.setSecurityManager(securityManager);
+ ExitUtil.resetFirstExitException();
+ ExitUtil.resetFirstHaltException();
}
+
/**
- * test methods run end execute of DistCp class. silple copy file
+ * test methods run end execute of DistCp class. simple copy file
* @throws Exception
*/
@Test
@@ -136,7 +140,7 @@ public void testCleanupTestViaToolRunner() throws IOException, InterruptedExcept
DistCp.main(arg);
fail();
- } catch (ExitException t) {
+ } catch (ExitUtil.ExitException t) {
assertTrue(fs.exists(target));
assertEquals(t.status, 0);
assertEquals(
@@ -175,33 +179,4 @@ public void testCleanupOfJob() throws Exception {
}
- private SecurityManager securityManager;
-
- protected static class ExitException extends SecurityException {
- private static final long serialVersionUID = -1982617086752946683L;
- public final int status;
-
- public ExitException(int status) {
- super("There is no escape!");
- this.status = status;
- }
- }
-
- private static class NoExitSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission perm) {
- // allow anything.
- }
-
- @Override
- public void checkPermission(Permission perm, Object context) {
- // allow anything.
- }
-
- @Override
- public void checkExit(int status) {
- super.checkExit(status);
- throw new ExitException(status);
- }
- }
}
diff --git a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
index 9fbc03c538a..8bcdd4fc9a7 100644
--- a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
+++ b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
@@ -181,8 +181,6 @@ public void testStressSubmit() throws Exception {
@Timeout(value = 100)
public void testMain() throws Exception {
- SecurityManager securityManager = System.getSecurityManager();
-
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
final PrintStream out = new PrintStream(bytes);
final PrintStream oldOut = System.out;
@@ -197,7 +195,6 @@ public void testMain() throws Exception {
ExitUtil.resetFirstExitException();
} finally {
System.setErr(oldOut);
- System.setSecurityManager(securityManager);
}
String print = bytes.toString();
// should be printed tip in std error stream
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org