kowshik commented on a change in pull request #11351:
URL: https://github.com/apache/kafka/pull/11351#discussion_r714401442



##########
File path: core/src/main/scala/kafka/utils/KafkaScheduler.scala
##########
@@ -103,11 +103,14 @@ class KafkaScheduler(val threads: Int,
     schedule(name, fun, delay = 0L, period = -1L, unit = TimeUnit.MILLISECONDS)
   }
 
-  def schedule(name: String, fun: () => Unit, delay: Long, period: Long, unit: 
TimeUnit): ScheduledFuture[_] = {
+  def schedule(name: String, fun: () => Unit, delay: Long, period: Long, unit: 
TimeUnit): Option[ScheduledFuture[_]] = {
     debug("Scheduling task %s with initial delay %d ms and period %d ms."
         .format(name, TimeUnit.MILLISECONDS.convert(delay, unit), 
TimeUnit.MILLISECONDS.convert(period, unit)))
     this synchronized {
-      ensureRunning()
+      if (!isStarted) {
+        info("Kafka scheduler is not running at the time task '%s' is 
scheduled. The task is ignored.".format(name))
+        return None

Review comment:
       With little bit refactor, it looks possible to avoid the `return` 
statement here.




-- 
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


Reply via email to