Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-7956

Avoid blocking in ShutdownableThread.awaitShutdown if the thread has not been started

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.0
    • Component/s: core
    • Labels:
      None

      Description

      Opening this Jira to track https://github.com/apache/kafka/pull/6218, since it's a rather subtle change.

      In some test cases it's desirable to instantiate a subclass of `ShutdownableThread` without starting it. Since most subclasses of `ShutdownableThread` put cleanup logic in `ShutdownableThread.shutdown()`, being able to call `shutdown()` on the non-running thread would be useful.

      This change allows us to avoid blocking in `ShutdownableThread.shutdown()` if the thread's `run()` method has not been called. We also add a check that `initiateShutdown()` was called before `awaitShutdown()`, to protect against the case where a user calls `awaitShutdown()` before the thread has been started, and unexpectedly is not blocked on the thread shutting down. 

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gardnervickers Gardner Vickers
                Reporter:
                gardnervickers Gardner Vickers
                Reviewer:
                Jun Rao
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: