From 32307a0d8f4ea36fd76418b5c15cdce26ec2eb3f Mon Sep 17 00:00:00 2001 From: Lucas Wang Date: Fri, 4 Nov 2022 15:46:38 -0700 Subject: [PATCH] [LI-HOTFIX] Add comment to explain the safety of the brokerEpochSupplier method TICKET = N/A LI_DESCRIPTION = Add comment to explain the safety of the brokerEpochSupplier method EXIT_CRITERIA = N/A --- core/src/main/scala/kafka/server/KafkaServer.scala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/scala/kafka/server/KafkaServer.scala b/core/src/main/scala/kafka/server/KafkaServer.scala index c6e99f1966b5..1f1ca4bd8738 100755 --- a/core/src/main/scala/kafka/server/KafkaServer.scala +++ b/core/src/main/scala/kafka/server/KafkaServer.scala @@ -350,6 +350,13 @@ class KafkaServer( time = time, metrics = metrics, threadNamePrefix = threadNamePrefix, + /** + * Since the kafkaController object is initialized later in this method, there is the question of whether the brokerEpochSupplier can + * trigger NullPointerExceptions. That should not happen because there is a implicit barrier: + * 1. The Partition objects are created when processing the LeaderAndISR requests, and only after they are created can the brokerEpochSupplier be called. + * 2. Processing an LeaderAndISR request won’t be possible until the {@link SocketServer.startProcessingRequests()} method is called + * toward the end of this method. + */ brokerEpochSupplier = () => kafkaController.brokerEpoch, config.brokerId )