Inspectopedia
 
2024.3

Identical 'catch' branches in 'try' statement

Warning
New
Last modified: 03 December 2024

Reports identical catch sections in a single try statement.

Collapsing such sections into one multi-catch block reduces code duplication and prevents the situations when one catch section is updated, and another one is not.

Example:

A quick-fix is available to make the code more compact:

This inspection depends on the Java feature 'Multi-catches', which is available since Java 7.