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

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


The following commit(s) were added to refs/heads/master by this push:
     new d2cfc871be [KYUUBI #7144] Remove direct usage of `sun.misc.Signal`
d2cfc871be is described below

commit d2cfc871be66ebdb546f855f17beeb424e7eb80b
Author: Cheng Pan <[email protected]>
AuthorDate: Mon Jul 28 15:29:27 2025 +0800

    [KYUUBI #7144] Remove direct usage of `sun.misc.Signal`
    
    ### Why are the changes needed?
    
    This PR replaces the `sun.misc.Signal` with the Kyuubi wrapped one, see 
https://github.com/apache/kyuubi-shaded/pull/64, which allows Kyuubi to use any 
of Java 8+ to compile with `-release:8` while still ensuring compatibility with 
Java 8.
    
    ### How was this patch tested?
    
    Pass GHA.
    
    Local tested by building against JDK 21, running on JDK 8, everything works 
as expected.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #7144 from pan3793/signal.
    
    Closes #7144
    
    64804060a [Cheng Pan] enforcer.maxJdkVersion
    2eb263573 [Cheng Pan] cleanup
    b699c345a [Cheng Pan] remove staging repo
    12eeae3ab [Cheng Pan] fix
    08eba7695 [Cheng Pan] RC
    53e4e6cce [Cheng Pan] Use Kyuubi Signal
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 kyuubi-common/pom.xml                              |  5 +++
 .../org/apache/kyuubi/util/SignalRegister.scala    | 10 +++--
 kyuubi-hive-beeline/pom.xml                        |  5 +++
 .../org/apache/hive/beeline/SunSignalHandler.java  |  4 +-
 pom.xml                                            | 45 ++++++++--------------
 5 files changed, 33 insertions(+), 36 deletions(-)

diff --git a/kyuubi-common/pom.xml b/kyuubi-common/pom.xml
index cb592948df..29a98ab7ff 100644
--- a/kyuubi-common/pom.xml
+++ b/kyuubi-common/pom.xml
@@ -108,6 +108,11 @@
             <artifactId>kyuubi-relocated-hive-service-rpc</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.kyuubi</groupId>
+            <artifactId>kyuubi-relocated-util</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.fasterxml.jackson.module</groupId>
             
<artifactId>jackson-module-scala_${scala.binary.version}</artifactId>
diff --git 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/util/SignalRegister.scala 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/util/SignalRegister.scala
index bff962f694..00294e9a21 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/util/SignalRegister.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/util/SignalRegister.scala
@@ -17,18 +17,20 @@
 
 package org.apache.kyuubi.util
 
+import java.util
 import java.util.Collections
 
 import scala.collection.JavaConverters._
+import scala.collection.mutable
 
 import org.apache.commons.lang3.SystemUtils
 import org.slf4j.Logger
-import sun.misc.{Signal, SignalHandler}
 
 import org.apache.kyuubi.Logging
+import org.apache.kyuubi.shaded.util.{Signal, SignalHandler}
 
 object SignalRegister extends Logging {
-  private val handlers = new scala.collection.mutable.HashMap[String, 
ActionHandler]
+  private val handlers = new mutable.HashMap[String, ActionHandler]
 
   def registerLogger(log: Logger): Unit = {
     Seq("TERM", "HUP", "INT").foreach { sig =>
@@ -41,7 +43,7 @@ object SignalRegister extends Logging {
               ActionHandler(signal)
             })
           handler.register({
-            log.error(s"RECEIVED SIGNAL ${signal.getNumber}: " + sig)
+            log.error(s"RECEIVED SIGNAL ${signal.getNumber}: $sig")
             false
           })
         } catch {
@@ -52,7 +54,7 @@ object SignalRegister extends Logging {
   }
 
   case class ActionHandler(signal: Signal) extends SignalHandler {
-    private val actions = Collections.synchronizedList(new 
java.util.LinkedList[() => Boolean])
+    private val actions = Collections.synchronizedList(new util.LinkedList[() 
=> Boolean])
     private val prevHandler: SignalHandler = Signal.handle(signal, this)
 
     override def handle(sig: Signal): Unit = {
diff --git a/kyuubi-hive-beeline/pom.xml b/kyuubi-hive-beeline/pom.xml
index dafae95099..32a602d6cb 100644
--- a/kyuubi-hive-beeline/pom.xml
+++ b/kyuubi-hive-beeline/pom.xml
@@ -46,6 +46,11 @@
             <version>${project.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.kyuubi</groupId>
+            <artifactId>kyuubi-relocated-util</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-client-api</artifactId>
diff --git 
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/SunSignalHandler.java
 
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/SunSignalHandler.java
index db4fc5b9e6..382d55709b 100644
--- 
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/SunSignalHandler.java
+++ 
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/SunSignalHandler.java
@@ -24,8 +24,8 @@ package org.apache.hive.beeline;
 
 import java.sql.SQLException;
 import java.sql.Statement;
-import sun.misc.Signal;
-import sun.misc.SignalHandler;
+import org.apache.kyuubi.shaded.util.Signal;
+import org.apache.kyuubi.shaded.util.SignalHandler;
 
 public class SunSignalHandler implements BeeLineSignalHandler, SignalHandler {
   private Statement stmt = null;
diff --git a/pom.xml b/pom.xml
index a1715243e3..cb1b977871 100644
--- a/pom.xml
+++ b/pom.xml
@@ -113,10 +113,10 @@
     </distributionManagement>
 
     <properties>
-        <java.version>8</java.version>
         <maven.version>3.9.10</maven.version>
-        <maven.compiler.source>${java.version}</maven.compiler.source>
-        <maven.compiler.target>${java.version}</maven.compiler.target>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <enforcer.maxJdkVersion>8</enforcer.maxJdkVersion>
         <scala.version>2.12.19</scala.version>
         <scala.binary.version>2.12</scala.binary.version>
         
<scala-collection-compat.version>2.12.0</scala-collection-compat.version>
@@ -310,6 +310,11 @@
                 <artifactId>kyuubi-relocated-hive-service-rpc</artifactId>
                 <version>${kyuubi-relocated.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.kyuubi</groupId>
+                <artifactId>kyuubi-relocated-util</artifactId>
+                <version>${kyuubi-relocated.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.apache.kyuubi</groupId>
                 
<artifactId>${kyuubi-relocated-zookeeper.artifacts}</artifactId>
@@ -1891,7 +1896,8 @@
                         <configuration>
                             <rules>
                                 <enforceBytecodeVersion>
-                                    
<maxJdkVersion>${java.version}</maxJdkVersion>
+                                    
<maxJdkVersion>${enforcer.maxJdkVersion}</maxJdkVersion>
+                                    <ignoredScopes>provided</ignoredScopes>
                                     <ignoredScopes>test</ignoredScopes>
                                     <ignoreClasses>
                                         <!--
@@ -1935,7 +1941,6 @@
                 <jdk>8</jdk>
             </activation>
             <properties>
-                <java.version>8</java.version>
                 <!--
                   Iceberg drops support for Java 8 since 1.7.0.
                   And it may have compatible issue with Spark 3.5.4+, see 
Iceberg #11731
@@ -1945,30 +1950,12 @@
         </profile>
 
         <profile>
-            <id>java-11</id>
-            <activation>
-                <jdk>11</jdk>
-            </activation>
-            <properties>
-                <java.version>11</java.version>
-                <maven.compiler.source></maven.compiler.source>
-                <maven.compiler.target></maven.compiler.target>
-                
<maven.compiler.release>${java.version}</maven.compiler.release>
-                
<minimalJavaBuildVersion>${java.version}</minimalJavaBuildVersion>
-            </properties>
-        </profile>
-
-        <profile>
-            <id>java-17</id>
+            <id>jdk9+</id>
             <activation>
-                <jdk>17</jdk>
+                <jdk>[9,)</jdk>
             </activation>
             <properties>
-                <java.version>17</java.version>
-                <maven.compiler.source></maven.compiler.source>
-                <maven.compiler.target></maven.compiler.target>
-                
<maven.compiler.release>${java.version}</maven.compiler.release>
-                
<minimalJavaBuildVersion>${java.version}</minimalJavaBuildVersion>
+                <maven.compiler.release>8</maven.compiler.release>
             </properties>
         </profile>
 
@@ -1978,10 +1965,6 @@
                 <jdk>21</jdk>
             </activation>
             <properties>
-                <java.version>21</java.version>
-                <maven.compiler.source></maven.compiler.source>
-                <maven.compiler.target></maven.compiler.target>
-                
<maven.compiler.release>${java.version}</maven.compiler.release>
                 <!-- TODO: The current version of spotless(2.30.0) and 
google-java-format(1.7)
                            does not support Java 21, but new version produces 
different outputs.
                            Re-evaluate once we dropped support for Java 8. -->
@@ -2064,6 +2047,7 @@
                 <module>extensions/spark/kyuubi-spark-connector-hive</module>
             </modules>
             <properties>
+                <enforcer.maxJdkVersion>17</enforcer.maxJdkVersion>
                 <spark.version>4.0.0</spark.version>
                 <spark.binary.version>4.0</spark.binary.version>
                 <antlr4.version>4.13.1</antlr4.version>
@@ -2084,6 +2068,7 @@
         <profile>
             <id>spark-master</id>
             <properties>
+                <enforcer.maxJdkVersion>17</enforcer.maxJdkVersion>
                 <spark.version>4.0.0-SNAPSHOT</spark.version>
                 <antlr4.version>4.13.1</antlr4.version>
                 
<maven.plugin.scalatest.exclude.tags>org.scalatest.tags.Slow,org.apache.kyuubi.tags.DeltaTest,org.apache.kyuubi.tags.IcebergTest,org.apache.kyuubi.tags.PaimonTest,org.apache.kyuubi.tags.HudiTest,org.apache.kyuubi.tags.PySparkTest</maven.plugin.scalatest.exclude.tags>

Reply via email to