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

dongjoon-hyun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 91dada14e239 [SPARK-60899][CORE][SQL][MLLIB][YARN] Replace APIs 
deprecated in Java 19 with their Java 21 counterparts
91dada14e239 is described below

commit 91dada14e239ea7861c931640b9c5653667fb58a
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Wed Nov 4 19:25:01 2026 -0800

    [SPARK-60899][CORE][SQL][MLLIB][YARN] Replace APIs deprecated in Java 19 
with their Java 21 counterparts
    
    ### What changes were proposed in this pull request?
    
    This PR replaces the calls to APIs deprecated in Java 19 with their Java 21 
counterparts:
    
    - `Thread#getId()` -> `Thread#threadId()` (37 call sites)
    - `new Locale(...)` -> `Locale.of(...)` (4 call sites)
    
    The other deprecated calls reported by the compiler (`new URL`, 
`ThreadDeath`, `Object#finalize`, `Subject#doAs`, `Unsafe#objectFieldOffset`) 
are not changed because they have no replacement with the same behavior.
    
    ### Why are the changes needed?
    
    SPARK-60669 raised the `-release` to 21, so these calls now produce 
deprecation warnings.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    - Compiled all modules, including the optional ones, with `build/sbt 
Test/compile` on JDK 21 and checked that no warning remains for the replaced 
calls.
    - Ran the existing suites that cover the changed code, e.g., 
`ExecutorSuite`, `AnalysisSuite`, `XmlSuite`, `RocksDBSuite`, 
`StopWordsRemoverSuite`, and `StringFunctionsSuite`.
    - Ran `dev/scalastyle` and `dev/lint-java`.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Sonnet 5.5
    
    Closes #60114 from dongjoon-hyun/SPARK-60899.
    
    Authored-by: Dongjoon Hyun <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 .../apache/spark/shuffle/sort/ShuffleExternalSorter.java   |  2 +-
 .../util/collection/unsafe/sort/UnsafeExternalSorter.java  |  2 +-
 .../scala/org/apache/spark/deploy/SparkHadoopUtil.scala    |  4 ++--
 .../main/scala/org/apache/spark/executor/Executor.scala    |  2 +-
 .../scala/org/apache/spark/util/collection/Spillable.scala |  2 +-
 core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala    |  2 +-
 .../org/apache/spark/ml/feature/StopWordsRemover.scala     |  2 +-
 .../org/apache/spark/deploy/yarn/ApplicationMaster.scala   |  2 +-
 .../sql/catalyst/expressions/ExpressionImplUtils.java      |  4 ++--
 .../main/scala/org/apache/spark/sql/internal/SQLConf.scala |  2 +-
 .../apache/spark/sql/catalyst/analysis/AnalysisSuite.scala |  4 ++--
 .../scala/org/apache/spark/sql/connect/ml/MLHandler.scala  |  4 ++--
 .../execution/streaming/state/RocksDBStateMachine.scala    |  2 +-
 .../src/test/scala/org/apache/spark/sql/QueryTest.scala    |  2 +-
 .../org/apache/spark/sql/execution/SparkPlanSuite.scala    |  2 +-
 .../spark/sql/execution/datasources/xml/XmlSuite.scala     |  4 ++--
 .../state/RocksDBCheckpointFailureInjectionSuite.scala     |  2 +-
 .../state/RocksDBStateStoreLockHardeningSuite.scala        |  6 +++---
 .../execution/streaming/state/RocksDBStateStoreSuite.scala |  6 +++---
 .../spark/sql/execution/streaming/state/RocksDBSuite.scala | 14 +++++++-------
 .../service/server/ThreadFactoryWithGarbageCleanup.java    |  2 +-
 .../hive/service/server/ThreadWithGarbageCleanup.java      |  4 ++--
 .../apache/spark/sql/pipelines/graph/GraphExecution.scala  |  2 +-
 23 files changed, 39 insertions(+), 39 deletions(-)

diff --git 
a/core/src/main/java/org/apache/spark/shuffle/sort/ShuffleExternalSorter.java 
b/core/src/main/java/org/apache/spark/shuffle/sort/ShuffleExternalSorter.java
index f899698cecb8..7d13fd9a4f36 100644
--- 
a/core/src/main/java/org/apache/spark/shuffle/sort/ShuffleExternalSorter.java
+++ 
b/core/src/main/java/org/apache/spark/shuffle/sort/ShuffleExternalSorter.java
@@ -171,7 +171,7 @@ final class ShuffleExternalSorter extends MemoryConsumer 
implements ShuffleCheck
       logger.info(
         "Task {} on Thread {} spilling sort data of {} to disk ({} {} so far)",
         MDC.of(LogKeys.TASK_ATTEMPT_ID, taskContext.taskAttemptId()),
-        MDC.of(LogKeys.THREAD_ID, Thread.currentThread().getId()),
+        MDC.of(LogKeys.THREAD_ID, Thread.currentThread().threadId()),
         MDC.of(LogKeys.MEMORY_SIZE, Utils.bytesToString(getMemoryUsage())),
         MDC.of(LogKeys.NUM_SPILLS, spills.size()),
         MDC.of(LogKeys.SPILL_TIMES, spills.size() != 1 ? "times" : "time"));
diff --git 
a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
 
b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
index aee32be4f3fa..cfb38b454bde 100644
--- 
a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
+++ 
b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
@@ -240,7 +240,7 @@ public final class UnsafeExternalSorter extends 
MemoryConsumer {
     }
 
     logger.info("Thread {} spilling sort data of {} to disk ({} {} so far)",
-      MDC.of(LogKeys.THREAD_ID, Thread.currentThread().getId()),
+      MDC.of(LogKeys.THREAD_ID, Thread.currentThread().threadId()),
       MDC.of(LogKeys.MEMORY_SIZE, Utils.bytesToString(getMemoryUsage())),
       MDC.of(LogKeys.NUM_SPILL_WRITERS, spillWriters.size()),
       MDC.of(LogKeys.SPILL_TIMES, spillWriters.size() > 1 ? "times" : "time"));
diff --git a/core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala 
b/core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala
index 4af2aa6394b1..633267c6f140 100644
--- a/core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala
+++ b/core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala
@@ -168,7 +168,7 @@ private[spark] class SparkHadoopUtil extends Logging {
    */
   private[spark] def getFSBytesReadOnThreadCallback(): () => Long = {
     val f = () => 
FileSystem.getAllStatistics.asScala.map(_.getThreadStatistics.getBytesRead).sum
-    val baseline = (Thread.currentThread().getId, f())
+    val baseline = (Thread.currentThread().threadId, f())
 
     /**
      * This function may be called in both spawned child threads and parent 
task thread (in
@@ -181,7 +181,7 @@ private[spark] class SparkHadoopUtil extends Logging {
 
       override def apply(): Long = {
         bytesReadMap.synchronized {
-          bytesReadMap.put(Thread.currentThread().getId, f())
+          bytesReadMap.put(Thread.currentThread().threadId, f())
           bytesReadMap.map { case (k, v) =>
             v - (if (k == baseline._1) baseline._2 else 0)
           }.sum
diff --git a/core/src/main/scala/org/apache/spark/executor/Executor.scala 
b/core/src/main/scala/org/apache/spark/executor/Executor.scala
index 3056c3b38ad6..cfbf0054b5d3 100644
--- a/core/src/main/scala/org/apache/spark/executor/Executor.scala
+++ b/core/src/main/scala/org/apache/spark/executor/Executor.scala
@@ -825,7 +825,7 @@ private[spark] class Executor(
       }
 
       setMDCForTask(taskName, mdcProperties)
-      threadId = Thread.currentThread.getId
+      threadId = Thread.currentThread.threadId
       Thread.currentThread.setName(threadName)
       val threadMXBean = ManagementFactory.getThreadMXBean
       val taskMemoryManager = new TaskMemoryManager(env.memoryManager, taskId)
diff --git 
a/core/src/main/scala/org/apache/spark/util/collection/Spillable.scala 
b/core/src/main/scala/org/apache/spark/util/collection/Spillable.scala
index a448ef5792d7..4f773ff88dc3 100644
--- a/core/src/main/scala/org/apache/spark/util/collection/Spillable.scala
+++ b/core/src/main/scala/org/apache/spark/util/collection/Spillable.scala
@@ -153,7 +153,7 @@ private[spark] abstract class 
Spillable[C](taskMemoryManager: TaskMemoryManager)
    * @param elements number of elements read from input since last spill
    */
   @inline private def logSpillage(size: Long, elements: Int): Unit = {
-    val threadId = Thread.currentThread().getId
+    val threadId = Thread.currentThread().threadId
     logInfo(log"Thread ${MDC(LogKeys.THREAD_ID, threadId)} " +
       log"spilling in-memory map of ${MDC(LogKeys.BYTE_SIZE,
         org.apache.spark.util.Utils.bytesToString(size))} " +
diff --git a/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala 
b/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
index 5ef10b6d7e2e..9a2b1fd785e2 100644
--- a/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
+++ b/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
@@ -1307,7 +1307,7 @@ class RDDSuite extends SparkFunSuite with 
SharedSparkContext with Eventually {
       })
       t.setDaemon(false)
       t.start()
-      tid.add(t.getId)
+      tid.add(t.threadId)
       Iterator(0)
     }.collect()
     val tmx = ManagementFactory.getThreadMXBean
diff --git 
a/mllib/src/main/scala/org/apache/spark/ml/feature/StopWordsRemover.scala 
b/mllib/src/main/scala/org/apache/spark/ml/feature/StopWordsRemover.scala
index 4bd1bfaf582d..5a98ca0bc4d3 100755
--- a/mllib/src/main/scala/org/apache/spark/ml/feature/StopWordsRemover.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/feature/StopWordsRemover.scala
@@ -143,7 +143,7 @@ class StopWordsRemover @Since("1.5.0") (@Since("1.5.0") 
override val uid: String
         terms.filter(s => !stopWordsSet.contains(s))
       }
     } else {
-      val lc = new Locale($(locale))
+      val lc = Locale.of($(locale))
       // scalastyle:off caselocale
       val toLower = (s: String) => if (s != null) s.toLowerCase(lc) else s
       // scalastyle:on caselocale
diff --git 
a/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala
 
b/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala
index 0cfe0a14ed11..6c4cbb8a8135 100644
--- 
a/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala
+++ 
b/resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala
@@ -549,7 +549,7 @@ private[spark] class ApplicationMaster(
     try {
       val dumps = Utils.getThreadDump()
       val sorted = Option(userClassThread) match {
-        case Some(t) => dumps.sortBy(d => if (d.threadId == t.getId) 0 else 1)
+        case Some(t) => dumps.sortBy(d => if (d.threadId == t.threadId) 0 else 
1)
         case None => dumps
       }
       logError(log"Thread dump on SparkContext initialization timeout:\n" +
diff --git 
a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
 
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
index 4f7446d0cd9c..2b307ac9c105 100644
--- 
a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
+++ 
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
@@ -351,9 +351,9 @@ public class ExpressionImplUtils {
     if (str == null) return null;
     Locale locale;
     if (language != null && country != null) {
-      locale = new Locale(language.toString(), country.toString());
+      locale = Locale.of(language.toString(), country.toString());
     } else if (language != null) {
-      locale = new Locale(language.toString());
+      locale = Locale.of(language.toString());
     } else {
       locale = Locale.US;
     }
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
index a5d9a2f322f9..166a0405ef43 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
@@ -315,7 +315,7 @@ object SQLConf {
       val isSchedulerEventLoopThread = SparkContext.getActive
         .flatMap { sc => Option(sc.dagScheduler) }
         .map(_.eventProcessLoop.eventThread)
-        .exists(_.getId == Thread.currentThread().getId)
+        .exists(_.threadId == Thread.currentThread().threadId)
       if (isSchedulerEventLoopThread) {
         // DAGScheduler event loop thread does not have an active 
SparkSession, the `confGetter`
         // will return `fallbackConf` which is unexpected. Here we require the 
caller to get the
diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
index 37101372260a..e40210e0e831 100644
--- 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
@@ -600,7 +600,7 @@ class AnalysisSuite extends AnalysisTest with Matchers {
     if (!bean.isThreadAllocatedMemoryEnabled) {
       bean.setThreadAllocatedMemoryEnabled(true)
     }
-    val threadId = Thread.currentThread().getId
+    val threadId = Thread.currentThread().threadId
     val sharedOutput = (0 until 26).map(i => AttributeReference(s"c$i", 
IntegerType)())
 
     def allocatedBytes(branchCount: Int): Long = {
@@ -640,7 +640,7 @@ class AnalysisSuite extends AnalysisTest with Matchers {
     if (!bean.isThreadAllocatedMemoryEnabled) {
       bean.setThreadAllocatedMemoryEnabled(true)
     }
-    val threadId = Thread.currentThread().getId
+    val threadId = Thread.currentThread().threadId
 
     def allocatedBytes(width: Int, useDirectPath: Boolean): Long = {
       val plan = wideProject(width)
diff --git 
a/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala
 
b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala
index e325f3b3e218..50b4b4b57b82 100644
--- 
a/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala
+++ 
b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala
@@ -185,7 +185,7 @@ private[connect] object MLHandler extends Logging {
             val execTime = System.currentTimeMillis() - startTime
             if (execTime > handlerInterruptionTimeoutMillis) {
               for (t <- Thread.getAllStackTraces().keySet().asScala) {
-                if (t.getId() == threadId) {
+                if (t.threadId() == threadId) {
                   t.interrupt()
                 }
               }
@@ -450,7 +450,7 @@ private[connect] object MLHandler extends Logging {
   def wrapHandler(
       originHandler: () => Any,
       reqProto: com.google.protobuf.GeneratedMessage): Any = {
-    val threadId = Thread.currentThread().getId
+    val threadId = Thread.currentThread().threadId
     val startTime = System.currentTimeMillis()
     handlerExecutionStartTimeMap.put(threadId, startTime)
     try {
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateMachine.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateMachine.scala
index 700b8b0ad490..25e16d945485 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateMachine.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateMachine.scala
@@ -341,6 +341,6 @@ case class AcquiredThreadInfo(
       s", task: $taskDetails"
     } else ""
 
-    s"[ThreadId: ${threadRef.get.map(_.getId)}$taskStr]"
+    s"[ThreadId: ${threadRef.get.map(_.threadId)}$taskStr]"
   }
 }
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala
index 04d633698604..7145a4817f68 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala
@@ -442,7 +442,7 @@ trait QueryTestBase
     val originalLocale = Locale.getDefault
     try {
       // Add Locale setting
-      Locale.setDefault(new Locale(language))
+      Locale.setDefault(Locale.of(language))
       f
     } finally {
       Locale.setDefault(originalLocale)
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala
index 45a0f4098bc5..de53f1625b37 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala
@@ -275,7 +275,7 @@ class SparkPlanSuite extends SharedSparkSession {
         if (!threadB.isAlive || System.currentTimeMillis() > deadline) {
           waiting = false
         } else {
-          val state = 
Option(bean.getThreadInfo(threadB.getId)).map(_.getThreadState).orNull
+          val state = 
Option(bean.getThreadInfo(threadB.threadId)).map(_.getThreadState).orNull
           if (state == Thread.State.BLOCKED) {
             threadBBlocked = true
             waiting = false
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala
index 7e92294fbd9c..80aa33edb6cd 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/xml/XmlSuite.scala
@@ -3909,7 +3909,7 @@ object XmlSuiteDebugFileSystem {
   }
 
   def open() : Unit = {
-    val threadId = Thread.currentThread().getId
+    val threadId = Thread.currentThread().threadId
     // assert that there are no open files for this executor
     assert(openCounterPerThread.getOrDefault(threadId, 0) == 0)
     openCounterPerThread.put(threadId, 1)
@@ -3917,7 +3917,7 @@ object XmlSuiteDebugFileSystem {
   }
 
   def close(): Unit = {
-    val threadId = Thread.currentThread().getId
+    val threadId = Thread.currentThread().threadId
     if (openCounterPerThread.get(threadId) == 1) {
       openCounterPerThread.put(threadId, 0)
     }
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBCheckpointFailureInjectionSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBCheckpointFailureInjectionSuite.scala
index a469ab36e0ab..ddec24c5277e 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBCheckpointFailureInjectionSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBCheckpointFailureInjectionSuite.scala
@@ -878,7 +878,7 @@ class RocksDBCheckpointFailureInjectionSuite extends 
StreamTest {
         conf = conf,
         localRootDir = Utils.createTempDir(),
         hadoopConf = hadoopConf,
-        loggingId = s"[Thread-${Thread.currentThread.getId}]",
+        loggingId = s"[Thread-${Thread.currentThread.threadId}]",
         useColumnFamilies = true,
         enableStateStoreCheckpointIds = enableStateStoreCheckpointIds,
         partitionId = 0,
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala
index 430789946c61..8f1fef80e9da 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreLockHardeningSuite.scala
@@ -796,10 +796,10 @@ class RocksDBStateStoreLockHardeningSuite extends 
SparkFunSuite
     val threadInfo = 
stateMachineObj.asInstanceOf[RocksDBStateMachine].getAcquiredThreadInfo
     assert(threadInfo.isDefined,
       "acquired thread info should not be null after load")
-    val threadId = threadInfo.get.threadRef.get.get.getId
+    val threadId = threadInfo.get.threadRef.get.get.threadId
     assert(
-      threadId == Thread.currentThread().getId,
-      s"acquired thread should be current thread 
${Thread.currentThread().getId} " +
+      threadId == Thread.currentThread().threadId,
+      s"acquired thread should be current thread 
${Thread.currentThread().threadId} " +
         s"after load but was $threadId")
   }
 }
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreSuite.scala
index e501366b7f98..75143591c02a 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreSuite.scala
@@ -3414,10 +3414,10 @@ class RocksDBStateStoreSuite extends 
StateStoreSuiteBase[RocksDBStateStoreProvid
     val threadInfo = 
stateMachineObj.asInstanceOf[RocksDBStateMachine].getAcquiredThreadInfo
     assert(threadInfo.isDefined,
       "acquired thread info should not be null after load")
-    val threadId = threadInfo.get.threadRef.get.get.getId
+    val threadId = threadInfo.get.threadRef.get.get.threadId
     assert(
-      threadId == Thread.currentThread().getId,
-      s"acquired thread should be curent thread 
${Thread.currentThread().getId} " +
+      threadId == Thread.currentThread().threadId,
+      s"acquired thread should be curent thread 
${Thread.currentThread().threadId} " +
         s"after load but was $threadId")
   }
 
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBSuite.scala
index eae45e755677..4137d3b17945 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBSuite.scala
@@ -4779,7 +4779,7 @@ class RocksDBSuite extends AlsoTestWithRocksDBFeatures 
with SharedSparkSession
       val db0 = new RocksDB(
         remoteDir, conf = conf, localRootDir = localDir0,
         hadoopConf = noOverwriteConf,
-        loggingId = s"[Thread-${Thread.currentThread.getId}]")
+        loggingId = s"[Thread-${Thread.currentThread.threadId}]")
       try {
         db0.load(0)
         db0.put("setup_key", "setup_value")
@@ -4807,7 +4807,7 @@ class RocksDBSuite extends AlsoTestWithRocksDBFeatures 
with SharedSparkSession
       val db1 = new RocksDB(
         remoteDir, conf = conf, localRootDir = localDir1,
         hadoopConf = noOverwriteConf,
-        loggingId = s"[Thread-${Thread.currentThread.getId}]")
+        loggingId = s"[Thread-${Thread.currentThread.threadId}]")
       try {
         db1.load(19)
         db1.put("key", "value_from_run1")
@@ -4839,7 +4839,7 @@ class RocksDBSuite extends AlsoTestWithRocksDBFeatures 
with SharedSparkSession
         conf = conf,
         localRootDir = localDir2,
         hadoopConf = noOverwriteConf,
-        loggingId = s"[Thread-${Thread.currentThread.getId}]")
+        loggingId = s"[Thread-${Thread.currentThread.threadId}]")
       try {
         db2.load(19)
         db2.put("key", "value_from_run2")
@@ -4879,7 +4879,7 @@ class RocksDBSuite extends AlsoTestWithRocksDBFeatures 
with SharedSparkSession
           conf = conf,
           localRootDir = localDir3,
           hadoopConf = noOverwriteConf,
-          loggingId = s"[Thread-${Thread.currentThread.getId}]")
+          loggingId = s"[Thread-${Thread.currentThread.threadId}]")
         try {
           db3.load(29)
           val value = new String(db3.get("key"), "UTF-8")
@@ -5206,7 +5206,7 @@ class RocksDBSuite extends AlsoTestWithRocksDBFeatures 
with SharedSparkSession
           conf = conf,
           localRootDir = localDir,
           hadoopConf = hadoopConf,
-          loggingId = s"[Thread-${Thread.currentThread.getId}]",
+          loggingId = s"[Thread-${Thread.currentThread.threadId}]",
           useColumnFamilies = useColumnFamilies,
           versionToUniqueId = versionToUniqueId)
       } else {
@@ -5215,7 +5215,7 @@ class RocksDBSuite extends AlsoTestWithRocksDBFeatures 
with SharedSparkSession
           conf = conf,
           localRootDir = localDir,
           hadoopConf = hadoopConf,
-          loggingId = s"[Thread-${Thread.currentThread.getId}]",
+          loggingId = s"[Thread-${Thread.currentThread.threadId}]",
           useColumnFamilies = useColumnFamilies)
       }
       db.load(version, versionToUniqueId.get(version))
@@ -5316,7 +5316,7 @@ object RocksDBSuite {
         dfsRootDir = Utils.createTempDir().getAbsolutePath,
         conf = RocksDBConf().copy(compactOnCommit = false, minVersionsToRetain 
= 100),
         hadoopConf = new Configuration(),
-        loggingId = s"[Thread-${Thread.currentThread.getId}]")
+        loggingId = s"[Thread-${Thread.currentThread.threadId}]")
 
       func
     } finally {
diff --git 
a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadFactoryWithGarbageCleanup.java
 
b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadFactoryWithGarbageCleanup.java
index 5a0cb102bedc..3a2929182e24 100644
--- 
a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadFactoryWithGarbageCleanup.java
+++ 
b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadFactoryWithGarbageCleanup.java
@@ -53,7 +53,7 @@ public class ThreadFactoryWithGarbageCleanup implements 
ThreadFactory {
   @Override
   public Thread newThread(Runnable runnable) {
     Thread newThread = new ThreadWithGarbageCleanup(runnable);
-    newThread.setName(namePrefix + ": Thread-" + newThread.getId());
+    newThread.setName(namePrefix + ": Thread-" + newThread.threadId());
     return newThread;
   }
 
diff --git 
a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadWithGarbageCleanup.java
 
b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadWithGarbageCleanup.java
index 9a1123d438b9..93bbf03034da 100644
--- 
a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadWithGarbageCleanup.java
+++ 
b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/server/ThreadWithGarbageCleanup.java
@@ -52,7 +52,7 @@ public class ThreadWithGarbageCleanup extends Thread {
   }
 
   private void cleanRawStore() {
-    Long threadId = this.getId();
+    Long threadId = this.threadId();
     RawStore threadLocalRawStore = threadRawStoreMap.get(threadId);
     if (threadLocalRawStore != null) {
       LOG.debug("RawStore: {}, for the thread: {} will be closed now.",
@@ -66,7 +66,7 @@ public class ThreadWithGarbageCleanup extends Thread {
    * Cache the ThreadLocal RawStore object. Called from the corresponding 
thread.
    */
   public void cacheThreadLocalRawStore() {
-    Long threadId = this.getId();
+    Long threadId = this.threadId();
     RawStore threadLocalRawStore = HiveMetaStore.HMSHandler.getRawStore();
     if (threadLocalRawStore != null && 
!threadRawStoreMap.containsKey(threadId)) {
       LOG.debug("Adding RawStore: {}, for the thread: {} " +
diff --git 
a/sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/GraphExecution.scala
 
b/sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/GraphExecution.scala
index db1e6c546da1..831dba9ee167 100644
--- 
a/sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/GraphExecution.scala
+++ 
b/sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/GraphExecution.scala
@@ -211,7 +211,7 @@ abstract class GraphExecution(
    */
   def stopThread(thread: Thread): Unit = {
     // Don't wait to join if current thread is the thread to stop
-    if (thread.getId != Thread.currentThread().getId) {
+    if (thread.threadId != Thread.currentThread().threadId) {
       
thread.join(env.spark.sessionState.conf.timeoutMsForTerminationJoinAndLock)
       // thread is alive after we join.
       if (thread.isAlive) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to