Details

      Description

      ScreenFopViewHandler.java:93, REC_CATCH_EXCEPTION

      • REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.widget.renderer.fo.ScreenFopViewHandler.render(String, String, String, String, String, HttpServletRequest, HttpServletResponse)

      This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try

      { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

      A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

      try { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... }

      ScreenFopViewHandler.java:193, REC_CATCH_EXCEPTION
      - REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.widget.renderer.fo.ScreenFopViewHandler.renderError(String, Exception, String, HttpServletRequest, HttpServletResponse)

      This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... }

      catch (Exception e)

      { something }

      as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

      A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

      try

      { ... }

      catch (RuntimeException e)

      { throw e; }

      catch (Exception e)

      { ... deal with all non-runtime exceptions ... }

        Activity

        Hide
        jleichert Julian Leichert added a comment -

        Added Multi-catches

        Show
        jleichert Julian Leichert added a comment - Added Multi-catches
        Hide
        mbrohl Michael Brohl added a comment -

        Hi Julian Leichert,

        thanks for your contribution.

        Due to changes in the class, the patch cannot be applied to the current codebase. Can you provide an updated patch?

        Thanks and regards,
        Michael

        Show
        mbrohl Michael Brohl added a comment - Hi Julian Leichert , thanks for your contribution. Due to changes in the class, the patch cannot be applied to the current codebase. Can you provide an updated patch? Thanks and regards, Michael
        Hide
        jleichert Julian Leichert added a comment -

        Hi Michael,
        I adapted the patch to the current codebase.

        Show
        jleichert Julian Leichert added a comment - Hi Michael, I adapted the patch to the current codebase.
        Hide
        mbrohl Michael Brohl added a comment -

        Thanks Julian,

        your patch is in trunk r1811700.

        Show
        mbrohl Michael Brohl added a comment - Thanks Julian, your patch is in trunk r1811700.

          People

          • Assignee:
            mbrohl Michael Brohl
            Reporter:
            jleichert Julian Leichert
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development