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

stoty pushed a commit to branch 5.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.2 by this push:
     new 07577b5c75 PHOENIX-7418 SystemExitRule errors out because of 
SecurityManager deprecation / removal (#1996)
07577b5c75 is described below

commit 07577b5c75afd76735562052b6a2ea3a110c7a32
Author: Istvan Toth <[email protected]>
AuthorDate: Wed Oct 9 14:28:09 2024 +0200

    PHOENIX-7418 SystemExitRule errors out because of SecurityManager 
deprecation / removal (#1996)
    
    run tests with -Djava.security.manager=allow
    Catch and log SecurityManager exceptions in SystemExitRule
---
 .../src/it/resources/scripts/execute_query.sh        |  5 +++--
 .../test/java/org/apache/phoenix/SystemExitRule.java | 12 +++++++++++-
 pom.xml                                              | 20 +++++++++++++++++++-
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/phoenix-core/src/it/resources/scripts/execute_query.sh 
b/phoenix-core/src/it/resources/scripts/execute_query.sh
index 26e037edbc..85b9cdcba7 100644
--- a/phoenix-core/src/it/resources/scripts/execute_query.sh
+++ b/phoenix-core/src/it/resources/scripts/execute_query.sh
@@ -37,6 +37,7 @@ mvn -B dependency:copy 
-Dartifact=${client_group_id}:${client_artifact_id}:${cli
 -DoutputDirectory=$tmp_dir
 
 phoenix_client_jar=$tmp_dir/${client_artifact_id}-${client_version}.jar
-java -cp ".:$phoenix_client_jar" sqlline.SqlLine -d 
org.apache.phoenix.jdbc.PhoenixDriver \
--u jdbc:phoenix:$zk_url -n none -p none --color=false --fastConnect=true 
--outputformat=csv \
+java -cp ".:$phoenix_client_jar" "-Djava.security.manager=allow" 
sqlline.SqlLine \
+-d org.apache.phoenix.jdbc.PhoenixDriver -u jdbc:phoenix:$zk_url -n none -p 
none \
+--color=false --fastConnect=true --outputformat=csv \
 --silent=true --verbose=false --isolation=TRANSACTION_READ_COMMITTED 
--run=$sqlfile &> $resultfile
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/SystemExitRule.java 
b/phoenix-core/src/test/java/org/apache/phoenix/SystemExitRule.java
index 0ec669ce84..f3e1092d26 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/SystemExitRule.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/SystemExitRule.java
@@ -20,6 +20,8 @@ package org.apache.phoenix;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Test rule that prevents System.exit / JVM exit to error out the test 
runner, which manages
@@ -28,6 +30,7 @@ import org.junit.runners.model.Statement;
  */
 public class SystemExitRule implements TestRule {
 
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(SystemExitRule.class);
     private static final SecurityManager SECURITY_MANAGER = new 
TestSecurityManager();
 
     @Override
@@ -38,8 +41,15 @@ public class SystemExitRule implements TestRule {
                 try {
                     System.setSecurityManager(SECURITY_MANAGER);
                     s.evaluate();
+                } catch (UnsupportedOperationException e) {
+                    LOGGER.warn("Was unable to set SecurityManager, JVM exits 
in tests will not be"
+                            + "handled correctly ", e);
                 } finally {
-                    System.setSecurityManager(null);
+                    try {
+                        System.setSecurityManager(null);
+                    } catch (UnsupportedOperationException e) {
+                        //We have logged a warning above already
+                    }
                 }
             }
 
diff --git a/pom.xml b/pom.xml
index b6c160e7a2..006b15c99d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -209,6 +209,10 @@
     </phoenix-surefire.jdk11.tuning.flags>
     <phoenix-surefire.jdk17.flags>--add-opens 
java.base/jdk.internal.util.random=ALL-UNNAMED</phoenix-surefire.jdk17.flags>
     <phoenix-surefire.jdk17.tuning.flags></phoenix-surefire.jdk17.tuning.flags>
+    <!-- This is needed for SystemExitRule to work correctly. This may mask 
related issues in
+    dependencies -->
+    
<phoenix-surefire.jdk21.flags>-Djava.security.manager=allow</phoenix-surefire.jdk21.flags>
+
     <!-- Surefire argLine defaults for Linux + JDK8 -->
     <argLine>${phoenix-surefire.argLine} ${phoenix-surefire.jdk8.tuning.flags} 
@{jacocoArgLine}</argLine>
 
@@ -2133,11 +2137,25 @@
     <profile>
       <id>build-with-jdk17</id>
       <activation>
-        <jdk>[17,)</jdk>
+        <jdk>[17,21)</jdk>
+      </activation>
+      <properties>
+        <argLine>${phoenix-surefire.jdk11.flags}
+          ${phoenix-surefire.jdk17.flags}
+          ${phoenix-surefire.jdk17.tuning.flags}
+          ${phoenix-surefire.argLine}
+          @{jacocoArgLine}</argLine>
+      </properties>
+    </profile>
+    <profile>
+      <id>build-with-jdk21</id>
+      <activation>
+        <jdk>[21,)</jdk>
       </activation>
       <properties>
         <argLine>${phoenix-surefire.jdk11.flags}
           ${phoenix-surefire.jdk17.flags}
+          ${phoenix-surefire.jdk21.flags}
           ${phoenix-surefire.jdk17.tuning.flags}
           ${phoenix-surefire.argLine}
           @{jacocoArgLine}</argLine>

Reply via email to