[ https://issues.apache.org/jira/browse/KAFKA-2605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15005823#comment-15005823 ]
ASF GitHub Bot commented on KAFKA-2605: --------------------------------------- GitHub user ZoneMayor opened a pull request: https://github.com/apache/kafka/pull/532 KAFKA-2605: Replace 'catch: Throwable' clauses with 'NonFatal' 'catch: Throwable' will catch VirtualMachineError, ThreadDeath, InterruptedException, LinkageError, ControlThrowable, NotImplementedError; we don't want to catch those kind of error You can merge this pull request into a Git repository by running: $ git pull https://github.com/ZoneMayor/kafka 0.8.2 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/532.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #532 ---- commit c466ef240e509c9aed7b2e7c6729df97abe89fff Author: jinxing <jinxing6...@126.com> Date: 2015-11-15T07:11:13Z KAFKA-2605: Replace 'catch: Throwable' clauses with 'NonFatal' ---- > 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.8.2.2 > 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.3.4#6332)