Pawan Verma created OFBIZ-11827:
-----------------------------------

             Summary: Merge identical catch blocks in single catch block 
                 Key: OFBIZ-11827
                 URL: https://issues.apache.org/jira/browse/OFBIZ-11827
             Project: OFBiz
          Issue Type: Improvement
          Components: ALL COMPONENTS
    Affects Versions: Trunk
            Reporter: Pawan Verma
            Assignee: Pawan Verma


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:
{code:java}
catch (IOException ex) {
    logger.log(ex);
    throw ex;
} catch (SQLException ex) {
    logger.log(ex);
    throw ex;
}{code}
Can be written as, which is valid in Java SE 7 and later, eliminates the 
duplicated code:

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



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to