kafka-jira mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Hurley (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KAFKA-2605) Replace `catch: Throwable` clauses with `NonFatal` or `NonControl`
Date Wed, 08 Nov 2017 17:13:00 GMT

    [ https://issues.apache.org/jira/browse/KAFKA-2605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16244333#comment-16244333
] 

Mike Hurley commented on KAFKA-2605:
------------------------------------

This isn't just a problem in the scala code. The ClientUtils.java file is also doing a catch
on Throwable which is intercepting a ThreadDeath I sent via Thread.stop(). (I know stop()
is deprecated but I need a hard stop for what I'm doing)

> Replace `catch: Throwable` clauses with `NonFatal` or `NonControl`
> ------------------------------------------------------------------
>
>                 Key: KAFKA-2605
>                 URL: https://issues.apache.org/jira/browse/KAFKA-2605
>             Project: Kafka
>          Issue Type: Improvement
>    Affects Versions: 0.11.0.0, 1.0.0
>            Reporter: Ismael Juma
>            Assignee: jin xing
>              Labels: newbie
>
> 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.4.14#64029)

Mime
View raw message