cmccabe commented on code in PR #12063: URL: https://github.com/apache/kafka/pull/12063#discussion_r853299678
########## core/src/main/scala/kafka/server/metadata/BrokerMetadataListener.scala: ########## @@ -248,6 +248,24 @@ class BrokerMetadataListener( } } + // This is used in tests to alter the publisher that is in use by the broker. + def alterPublisher(publisher: MetadataPublisher): CompletableFuture[Void] = { + val event = new AlterPublisherEvent(publisher) + eventQueue.append(event) + event.future + } + + class AlterPublisherEvent(publisher: MetadataPublisher) + extends EventQueue.FailureLoggingEvent(log) { + val future = new CompletableFuture[Void]() + + override def run(): Unit = { + _publisher = Some(publisher) + log.info(s"Set publisher to ${publisher}") Review Comment: @mdedetrich : Thanks for the comment. I would like to put this code outside of `BrokerMetadataListener`, but that would mean making `_publisher` public (or at least non-private) which is something I really don't want to do. People have a tendency to use whatever variables are available to them in junit tests, even if there are concurrency problems. We have a lot of examples of that. This function is more like a setter. It's simple enough to just put in the code. -- 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