[ 
https://issues.apache.org/jira/browse/SAMZA-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jagadish updated SAMZA-1077:
----------------------------
    Description: 
Here's the snippet from the startup sequence of the SamzaContainer.

{code:title=SamzaContainer.scala|borderStyle=solid}
      startProducers
      startTask
      startConsumers
      startSecurityManger

      info("Entering run loop.")
      addShutdownHook
      runLoop.run
    } catch {
      case e: Exception =>
        error("Caught exception in process loop.", e)
        throw e
    } finally {
      info("Shutting down.")

      shutdownConsumers
      shutdownTask
      shutdownStores
{code}


In this case, the catch block merely catches Exceptions and not Errors. 

Consider the following sequence:
1. `NoSuchMethodError` thrown in the startup sequence. 
2. The error is not caught in the catch block.
3. The f
Catching all Throwables will prevent this.

  was:
Here's the snippet from the startup sequence of the SamzaContainer.

{code:title=SamzaContainer.scala|borderStyle=solid}
      startProducers
      startTask
      startConsumers
      startSecurityManger

      info("Entering run loop.")
      addShutdownHook
      runLoop.run
    } catch {
      case e: Exception =>
        error("Caught exception in process loop.", e)
        throw e
    } finally {
      info("Shutting down.")

      shutdownConsumers
      shutdownTask
      shutdownStores
{code}


In this case, the catch block should catch all Throwables instead of merely 
catching Exceptions. This will cause errors like `NoSuchMethodErrors` to be 
masked. Furthermore, the error can get lost completely if the finally block 
throws an exception during any of the shutdown calls.

Catching all Throwables will prevent this.


> SamzaContainer should catch all Throwables instead of only exceptions
> ---------------------------------------------------------------------
>
>                 Key: SAMZA-1077
>                 URL: https://issues.apache.org/jira/browse/SAMZA-1077
>             Project: Samza
>          Issue Type: Bug
>            Reporter: Jagadish
>
> Here's the snippet from the startup sequence of the SamzaContainer.
> {code:title=SamzaContainer.scala|borderStyle=solid}
>       startProducers
>       startTask
>       startConsumers
>       startSecurityManger
>       info("Entering run loop.")
>       addShutdownHook
>       runLoop.run
>     } catch {
>       case e: Exception =>
>         error("Caught exception in process loop.", e)
>         throw e
>     } finally {
>       info("Shutting down.")
>       shutdownConsumers
>       shutdownTask
>       shutdownStores
> {code}
> In this case, the catch block merely catches Exceptions and not Errors. 
> Consider the following sequence:
> 1. `NoSuchMethodError` thrown in the startup sequence. 
> 2. The error is not caught in the catch block.
> 3. The f
> Catching all Throwables will prevent this.



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

Reply via email to