You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2024/05/23 06:24:41 UTC
(kyuubi) branch master updated: [KYUUBI #6410] Check if asyncRequestExecutor is initialized before shutdown
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 a95ff125f [KYUUBI #6410] Check if asyncRequestExecutor is initialized before shutdown
a95ff125f is described below
commit a95ff125fc7a6bc1ebc78cda551e1ae9e5e0dac9
Author: wforget <64...@qq.com>
AuthorDate: Thu May 23 14:24:30 2024 +0800
[KYUUBI #6410] Check if asyncRequestExecutor is initialized before shutdown
# :mag: Description
## Issue References ๐
This pull request fixes #6410
## Describe Your Solution ๐ง
Check if asyncRequestExecutor is initialized before shutdown to avoid NPE.
## Types of changes :bookmark:
- [X] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklist ๐
- [X] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #6414 from wForget/KYUUBI-6410.
Closes #6410
1b7d35efe [wforget] comment
b83ea22cf [wforget] Check if asyncRequestExecutor is initialized before shutdown
Authored-by: wforget <64...@qq.com>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
.../scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala
index 9628613a6..7133131d7 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala
@@ -69,9 +69,12 @@ class KyuubiSyncThriftClient private (
private var engineAliveThreadPool: ScheduledExecutorService = _
@volatile private var engineLastAlive: Long = _
- private lazy val asyncRequestExecutor: ExecutorService =
+ @volatile private var asyncRequestExecutorInitialized: Boolean = false
+ private lazy val asyncRequestExecutor: ExecutorService = {
+ asyncRequestExecutorInitialized = true
ThreadUtils.newDaemonSingleThreadScheduledExecutor(
"async-request-executor-" + SessionHandle(_remoteSessionHandle))
+ }
@VisibleForTesting
@volatile private[kyuubi] var asyncRequestInterrupted: Boolean = false
@@ -80,7 +83,9 @@ class KyuubiSyncThriftClient private (
private[kyuubi] def getEngineAliveProbeProtocol: Option[TProtocol] = engineAliveProbeProtocol
private def shutdownAsyncRequestExecutor(): Unit = {
- Option(asyncRequestExecutor).filterNot(_.isShutdown).foreach(ThreadUtils.shutdown(_))
+ if (asyncRequestExecutorInitialized && !asyncRequestExecutor.isShutdown) {
+ ThreadUtils.shutdown(asyncRequestExecutor)
+ }
asyncRequestInterrupted = true
}