Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-11827

Merge identical catch blocks in single catch block

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Implemented
    • Trunk
    • None
    • ALL COMPONENTS
    • None

    Description

      In Java SE 7 and later, a single catch block can handle more than one type of exception. This feature can reduce code duplication and lessen the temptation to catch an overly broad exception.

      For more details: https://docs.oracle.com/javase/8/docs/technotes/guides/language/catch-multiple.html

      Example:

      catch (IOException ex) {
          logger.log(ex);
          throw ex;
      } catch (SQLException ex) {
          logger.log(ex);
          throw ex;
      }

      Can be written as, which is valid in Java SE 7 and later, eliminates the duplicated code:

       

      catch (IOException | SQLException ex) {
          logger.log(ex);
          throw ex;
      }

       

      Attachments

        1. OFBIZ-11827.patch
          106 kB
          Pawan Verma
        2. OFBIZ-11827-plugins.patch
          41 kB
          Pawan Verma

        Activity

          People

            pawan Pawan Verma
            pawan Pawan Verma
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: