This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-1.9
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.9 by this push:
new 5fffdc048 [KYUUBI #6410] Check if asyncRequestExecutor is initialized
before shutdown
5fffdc048 is described below
commit 5fffdc048923d119121ec10dd8628abfcc851a22
Author: wforget <[email protected]>
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 <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit a95ff125fc7a6bc1ebc78cda551e1ae9e5e0dac9)
Signed-off-by: Cheng Pan <[email protected]>
---
.../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
}