kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ismael Juma (JIRA)" <j...@apache.org>
Subject [jira] [Created] (KAFKA-2605) Replace `catch: Throwable` clauses with `NonFatal` or `NonControl`
Date Fri, 02 Oct 2015 11:56:26 GMT
Ismael Juma created KAFKA-2605:
----------------------------------

             Summary: Replace `catch: Throwable` clauses with `NonFatal` or `NonControl`
                 Key: KAFKA-2605
                 URL: https://issues.apache.org/jira/browse/KAFKA-2605
             Project: Kafka
          Issue Type: Bug
    Affects Versions: 0.8.2.2
            Reporter: Ismael Juma


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:

{code}
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
}
{code}

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

{code}
  case e: ControlThrowable => throw e
  case e: Throwable => ...
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message