You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ed...@apache.org on 2025/02/11 11:45:46 UTC
(kafka) branch 4.0 updated: KAFKA-18758: NullPointerException in shutdown following InvalidConfigurationException (#18833)
This is an automated email from the ASF dual-hosted git repository.
edocomar pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/4.0 by this push:
new 7fb38797994 KAFKA-18758: NullPointerException in shutdown following InvalidConfigurationException (#18833)
7fb38797994 is described below
commit 7fb38797994b4a9a4db09ab170109996445cdcbf
Author: Edoardo Comar <ec...@uk.ibm.com>
AuthorDate: Tue Feb 11 10:06:55 2025 +0000
KAFKA-18758: NullPointerException in shutdown following InvalidConfigurationException (#18833)
* KAFKA-18758: NullPointerException in shutdown following InvalidConfigurationException
Add checks for null in shutdown as BrokerLifecycleManager is not instantiaited if LogManager constructor throws an Exception
---
.../src/main/scala/kafka/server/BrokerServer.scala | 34 +++++++++++++---------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/core/src/main/scala/kafka/server/BrokerServer.scala b/core/src/main/scala/kafka/server/BrokerServer.scala
index 122a469180b..510e7639b01 100644
--- a/core/src/main/scala/kafka/server/BrokerServer.scala
+++ b/core/src/main/scala/kafka/server/BrokerServer.scala
@@ -749,18 +749,22 @@ class BrokerServer(
if (replicaManager != null)
replicaManager.beginControlledShutdown()
- lifecycleManager.beginControlledShutdown()
- try {
- val controlledShutdownTimeoutMs = deadline - time.milliseconds()
- lifecycleManager.controlledShutdownFuture.get(controlledShutdownTimeoutMs, TimeUnit.MILLISECONDS)
- } catch {
- case _: TimeoutException =>
- error("Timed out waiting for the controller to approve controlled shutdown")
- case e: Throwable =>
- error("Got unexpected exception waiting for controlled shutdown future", e)
+ if (lifecycleManager != null) {
+ lifecycleManager.beginControlledShutdown()
+ try {
+ val controlledShutdownTimeoutMs = deadline - time.milliseconds()
+ lifecycleManager.controlledShutdownFuture.get(controlledShutdownTimeoutMs, TimeUnit.MILLISECONDS)
+ } catch {
+ case _: TimeoutException =>
+ error("Timed out waiting for the controller to approve controlled shutdown")
+ case e: Throwable =>
+ error("Got unexpected exception waiting for controlled shutdown future", e)
+ }
}
}
- lifecycleManager.beginShutdown()
+ if (lifecycleManager != null)
+ lifecycleManager.beginShutdown()
+
// Stop socket server to stop accepting any more connections and requests.
// Socket server will be shutdown towards the end of the sequence.
if (socketServer != null) {
@@ -815,8 +819,10 @@ class BrokerServer(
if (clientToControllerChannelManager != null)
CoreUtils.swallow(clientToControllerChannelManager.shutdown(), this)
- if (logManager != null)
- CoreUtils.swallow(logManager.shutdown(lifecycleManager.brokerEpoch), this)
+ if (logManager != null) {
+ val brokerEpoch = if (lifecycleManager != null) lifecycleManager.brokerEpoch else -1
+ CoreUtils.swallow(logManager.shutdown(brokerEpoch), this)
+ }
// Close remote log manager to give a chance to any of its underlying clients
// (especially in RemoteStorageManager and RemoteLogMetadataManager) to close gracefully.
@@ -836,7 +842,9 @@ class BrokerServer(
isShuttingDown.set(false)
- CoreUtils.swallow(lifecycleManager.close(), this)
+ if (lifecycleManager != null)
+ CoreUtils.swallow(lifecycleManager.close(), this)
+
CoreUtils.swallow(config.dynamicConfig.clear(), this)
Utils.closeQuietly(clientMetricsManager, "client metrics manager")
sharedServer.stopForBroker()