[
https://issues.apache.org/jira/browse/HADOOP-19526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947152#comment-17947152
]
ASF GitHub Bot commented on HADOOP-19526:
-----------------------------------------
cnauroth commented on code in PR #7567:
URL: https://github.com/apache/hadoop/pull/7567#discussion_r2059255067
##########
hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestExternalCall.java:
##########
@@ -65,8 +66,12 @@ private static Configuration getConf() {
@BeforeEach
public void setup() {
- securityManager = System.getSecurityManager();
- System.setSecurityManager(new NoExitSecurityManager());
+ try {
+ securityManager = System.getSecurityManager();
+ System.setSecurityManager(new NoExitSecurityManager());
+ } catch (UnsupportedOperationException e) {
+ assumeTrue(false, "Test is skipped because SecurityManager cannot be set
(JEP 411)");
Review Comment:
Thank you for fixing this, @stoty . It seems like this will result in loss
of test coverage on JDK 24. A couple of potential ideas:
1. I think only `testCleanupTestViaToolRunner` actually depends on modifying
security manager to catch a `System.exit` call. We could push the `assumeTrue`
and all of the security manager modification down into just that method, and
the other test methods could continue running on JDK 24.
2. We could potentially modify `DistCp` so that instead of directly calling
`System.exit`, it holds a `Consumer<Integer> exitHandler`. By default, this is
set to `System::exit`, but we also have a `VisibleForTesting` constructor that
accepts an override. Tests can override it to assert on the exit code instead
of a real `System.exit`. This technique would totally remove the security
manager dependency so that all tests can run across all JDK versions.
Let me know your thoughts. Thanks!
> Skip tests in Hadoop common that depend on SecurityManager if the JVM does
> not support it
> -----------------------------------------------------------------------------------------
>
> Key: HADOOP-19526
> URL: https://issues.apache.org/jira/browse/HADOOP-19526
> Project: Hadoop Common
> Issue Type: Improvement
> Reporter: Istvan Toth
> Assignee: Istvan Toth
> Priority: Major
> Labels: pull-request-available
>
> TestExternalCall fails when SecurityManager cannot be set, we need to skip it
> on thos JVMs.
> TestGridmixSubmission has already been rewritten to use ExitUtil, we just
> need to remove the leftover SecurityManager calls.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]