Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-2395

Check Scala catch blocks for Throwable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Build System, Scala API
    • Labels:
      None

      Description

      As described in [1], it's not a good practice to catch Throwables in Scala catch blocks because Scala uses some special exceptions for the control flow. Therefore we should check whether we can restrict ourselves to only catching subtypes of Throwable, such as Exception, instead.

      [1] https://www.sumologic.com/2014/05/05/why-you-should-never-catch-throwable-in-scala/

        Activity

        Hide
        uce Ufuk Celebi added a comment -

        Interesting link. Thanks for sharing!

        Show
        uce Ufuk Celebi added a comment - Interesting link. Thanks for sharing!
        Hide
        StephanEwen Stephan Ewen added a comment -

        At some points, catch Throwable is probably okay, such as at root points in the JobManager / TaskManager process initialization.

        Show
        StephanEwen Stephan Ewen added a comment - At some points, catch Throwable is probably okay, such as at root points in the JobManager / TaskManager process initialization.
        Hide
        mxm Maximilian Michels added a comment -

        On the master, we currently have 72 Throwable catch blocks in the Scala code. Probably most of them can be safely converted to catch Exception instead. Some corner cases may remain, e.g. Hadoop uses FSError subclassed from Throwable to signalize file system errors but that should be handled by Java code. Then of course there are virtual machine errors like OutOfMemoryError.

        Show
        mxm Maximilian Michels added a comment - On the master, we currently have 72 Throwable catch blocks in the Scala code. Probably most of them can be safely converted to catch Exception instead. Some corner cases may remain, e.g. Hadoop uses FSError subclassed from Throwable to signalize file system errors but that should be handled by Java code. Then of course there are virtual machine errors like OutOfMemoryError .
        Hide
        mingleizhang mingleizhang added a comment -

        The link was broken. 404 error.

        Show
        mingleizhang mingleizhang added a comment - The link was broken. 404 error.
        Hide
        till.rohrmann Till Rohrmann added a comment -

        I think this issue can be closed since we are removing the Scala components anyway quite soon.

        Show
        till.rohrmann Till Rohrmann added a comment - I think this issue can be closed since we are removing the Scala components anyway quite soon.

          People

          • Assignee:
            Unassigned
            Reporter:
            till.rohrmann Till Rohrmann
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development