xvrl commented on code in PR #11998: URL: https://github.com/apache/kafka/pull/11998#discussion_r845459993
########## core/src/test/scala/integration/kafka/server/DynamicBrokerReconfigurationTest.scala: ########## @@ -1813,14 +1812,20 @@ class TestMetricsReporter extends MetricsReporter with Reconfigurable with Close import TestMetricsReporter._ val kafkaMetrics = ArrayBuffer[KafkaMetric]() @volatile var initializeCount = 0 + @volatile var contextChangeCount = 0 @volatile var configureCount = 0 @volatile var reconfigureCount = 0 @volatile var closeCount = 0 @volatile var clusterUpdateCount = 0 @volatile var pollingInterval: Int = -1 testReporters.add(this) + override def contextChange(metricsContext: MetricsContext): Unit = { + contextChangeCount += 1 + } + override def init(metrics: util.List[KafkaMetric]): Unit = { + assertTrue(contextChangeCount > 0, "contextChange must be called before init") Review Comment: we technically don't specify exactly how many times it gets called before, but in practice it's once yes. We could certainly evolve the contract and be more explicit -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org