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

Replace `catch: Throwable` clauses with `NonFatal` or `NonControl`

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 0.11.0.0, 1.0.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      The Kafka codebase includes a number of instances where we do `catch t: Throwable` where we should really be doing `catch NonFatal(t)` or `catch NonControl(t)` where `NonFatal` is part of the standard library and `NonControl` is something like:

      object NonControl {
         def apply(t: Throwable): Boolean = t match {
           case _: ControlThrowable => false
           case _ => true
         }
        def unapply(t: Throwable): Option[Throwable] = if (apply(t)) Some(t) else None
      }
      

      We can also use `NonControl` to replace cases like (it's more concise and has the same behaviour):

        case e: ControlThrowable => throw e
        case e: Throwable => ...
      

        Attachments

          Activity

            People

            • Assignee:
              jinxing6042@126.com jin xing
              Reporter:
              ijuma Ismael Juma
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: