From d3dcf0474afa45e1b1dae208dd00e6ccc19a5ef3 Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Thu, 20 Aug 2015 21:22:52 +0200 Subject: [PATCH] Use multi-catch in test code. #1555 Fixes `TryWithIdenticalCatches` inspection violations in test code. Description: >Reports identical catch sections in try blocks under JDK 7. A quickfix is available to collapse the sections into a multi-catch section. This inspection only reports if the project or module is configured to use a language level of 7.0 or higher. --- .../puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java | 5 +---- src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java index a793da549..d0d923a2e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java @@ -486,10 +486,7 @@ public class ConfigurationLoaderTest { final Configuration[] children = config.getChildren(); assertEquals(0, children[0].getChildren().length); } - catch (CheckstyleException ex) { - fail("unexpected exception"); - } - catch (FileNotFoundException e) { + catch (CheckstyleException | FileNotFoundException ex) { fail("unexpected exception"); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java index 265e7975d..f3c66770c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/UtilsTest.java @@ -233,10 +233,7 @@ public class UtilsTest { assertEquals("given id " + id, expected.getMessage()); } - catch (IllegalAccessException e) { - fail(); - } - catch (NoSuchFieldException e) { + catch (IllegalAccessException | NoSuchFieldException e) { fail(); } }