You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/09/23 00:42:54 UTC

[GitHub] [kafka] kowshik commented on a change in pull request #11351: KAFKA-13315: log layer exception during shutdown that caused an unclean shutdown

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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org