From f65b17cbc30795247fef3077cce16a8bb53e9ffc Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Sun, 22 Nov 2015 00:14:51 +0100 Subject: [PATCH] Issue #2616: Fix CatchParameterName check violations in Checkstyle code --- .../test/base/BaseCheckTestSupport.java | 2 +- .../tools/checkstyle/ConfigurationLoader.java | 14 ++++++------- .../com/puppycrawl/tools/checkstyle/Main.java | 8 ++++---- .../tools/checkstyle/PackageNamesLoader.java | 12 +++++------ .../checkstyle/PackageObjectFactory.java | 4 ++-- .../tools/checkstyle/TreeWalker.java | 4 ++-- .../checkstyle/ant/CheckstyleAntTask.java | 16 +++++++-------- .../tools/checkstyle/api/AutomaticBean.java | 8 ++++---- .../checks/AbstractFormatCheck.java | 4 ++-- .../checkstyle/checks/TranslationCheck.java | 4 ++-- .../checks/UniquePropertiesCheck.java | 4 ++-- .../checks/blocks/EmptyCatchBlockCheck.java | 4 ++-- .../checks/imports/ImportControlLoader.java | 16 +++++++-------- .../checks/javadoc/AbstractJavadocCheck.java | 4 ++-- .../SuppressWithNearbyCommentFilter.java | 10 +++++----- .../filters/SuppressionCommentFilter.java | 4 ++-- .../filters/SuppressionsLoader.java | 20 +++++++++---------- .../tools/checkstyle/utils/CommonUtils.java | 12 +++++------ .../checkstyle/BaseCheckTestSupport.java | 2 +- .../checkstyle/CommitValidationTest.java | 2 +- .../checkstyle/ConfigurationLoaderTest.java | 6 +++--- .../puppycrawl/tools/checkstyle/MainTest.java | 20 +++++++++---------- .../checkstyle/PropertyCacheFileTest.java | 6 +++--- .../tools/checkstyle/TreeWalkerTest.java | 4 ++-- .../tools/checkstyle/XDocsPagesTest.java | 10 +++++----- .../tools/checkstyle/api/FileTextTest.java | 4 ++-- .../checkstyle/checks/ClassResolverTest.java | 16 +++++++-------- .../coding/FinalLocalVariableCheckTest.java | 2 +- .../coding/IllegalInstantiationCheckTest.java | 2 +- .../checks/coding/IllegalTypeCheckTest.java | 2 +- .../ModifiedControlVariableCheckTest.java | 4 ++-- .../coding/ParameterAssignmentCheckTest.java | 4 ++-- .../checks/coding/ReturnCountCheckTest.java | 4 ++-- .../design/MutableExceptionCheckTest.java | 2 +- .../checks/design/ThrowsCountCheckTest.java | 4 ++-- .../imports/ImportControlLoaderTest.java | 8 ++++---- .../CommentsIndentationCheckTest.java | 4 ++-- .../NoWhitespaceAfterCheckTest.java | 4 ++-- .../filters/SuppressionsLoaderTest.java | 2 +- .../javadoc/JavadocParseTreeTest.java | 2 +- .../checkstyle/utils/TokenUtilsTest.java | 2 +- 41 files changed, 133 insertions(+), 133 deletions(-) diff --git a/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java b/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java index d07b6863e..fa56d01c5 100644 --- a/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java +++ b/src/it/java/com/google/checkstyle/test/base/BaseCheckTestSupport.java @@ -165,7 +165,7 @@ public class BaseCheckTestSupport { try { pr.load(aClass.getResourceAsStream("messages.properties")); } - catch (IOException e) { + catch (IOException ex) { return null; } final MessageFormat formatter = new MessageFormat(pr.getProperty(messageKey), diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java b/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java index 9084a77d5..ec1a71b27 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java @@ -231,14 +231,14 @@ public final class ConfigurationLoader { loader.parseInputSource(configSource); return loader.configuration; } - catch (final SAXParseException e) { + catch (final SAXParseException ex) { final String message = String.format(Locale.ROOT, "%s - %s:%s:%s", UNABLE_TO_PARSE_EXCEPTION_PREFIX, - e.getMessage(), e.getLineNumber(), e.getColumnNumber()); - throw new CheckstyleException(message, e); + ex.getMessage(), ex.getLineNumber(), ex.getColumnNumber()); + throw new CheckstyleException(message, ex); } - catch (final ParserConfigurationException | IOException | SAXException e) { - throw new CheckstyleException(UNABLE_TO_PARSE_EXCEPTION_PREFIX, e); + catch (final ParserConfigurationException | IOException | SAXException ex) { + throw new CheckstyleException(UNABLE_TO_PARSE_EXCEPTION_PREFIX, ex); } } @@ -482,8 +482,8 @@ public final class ConfigurationLoader { final String severity = recentModule.getAttribute(SEVERITY); level = SeverityLevel.getInstance(severity); } - catch (final CheckstyleException e) { - LOG.debug("Severity not set, ignoring exception", e); + catch (final CheckstyleException ex) { + LOG.debug("Severity not set, ignoring exception", ex); } // omit this module if these should be omitted and the module diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/Main.java b/src/main/java/com/puppycrawl/tools/checkstyle/Main.java index 49f5d6e50..66af80e88 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/Main.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/Main.java @@ -129,10 +129,10 @@ public final class Main { System.out.println(pex.getMessage()); printUsage(); } - catch (CheckstyleException e) { + catch (CheckstyleException ex) { exitStatus = EXIT_WITH_CHECKSTYLE_EXCEPTION_CODE; errorCounter = 1; - e.printStackTrace(); + ex.printStackTrace(); } finally { // return exit code base on validation of Checker @@ -300,9 +300,9 @@ public final class Main { fis = new FileInputStream(file); properties.load(fis); } - catch (final IOException e) { + catch (final IOException ex) { throw new CheckstyleException(String.format( - "Unable to load properties from file '%s'.", file.getAbsolutePath()), e); + "Unable to load properties from file '%s'.", file.getAbsolutePath()), ex); } finally { Closeables.closeQuietly(fis); diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/PackageNamesLoader.java b/src/main/java/com/puppycrawl/tools/checkstyle/PackageNamesLoader.java index 414550b94..bd31da08b 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/PackageNamesLoader.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/PackageNamesLoader.java @@ -149,8 +149,8 @@ public final class PackageNamesLoader final InputSource source = new InputSource(stream); namesLoader.parseInputSource(source); } - catch (IOException e) { - throw new CheckstyleException("unable to open " + packageFile, e); + catch (IOException ex) { + throw new CheckstyleException("unable to open " + packageFile, ex); } finally { Closeables.closeQuietly(stream); @@ -160,11 +160,11 @@ public final class PackageNamesLoader result = namesLoader.packageNames; } - catch (IOException e) { - throw new CheckstyleException("unable to get package file resources", e); + catch (IOException ex) { + throw new CheckstyleException("unable to get package file resources", ex); } - catch (ParserConfigurationException | SAXException e) { - throw new CheckstyleException("unable to open one of package files", e); + catch (ParserConfigurationException | SAXException ex) { + throw new CheckstyleException("unable to open one of package files", ex); } return result; diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java index 33f5423a7..5ef6007d8 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java @@ -157,12 +157,12 @@ class PackageObjectFactory implements ModuleFactory { try { return doMakeObject(name + "Check"); } - catch (final CheckstyleException ex2) { + catch (final CheckstyleException ex) { final LocalizedMessage exceptionMessage = new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, UNABLE_TO_INSTANTIATE_EXCEPTION_MESSAGE, new String[] {name, joinPackageNamesWithClassName(name)}, null, getClass(), null); - throw new CheckstyleException(exceptionMessage.getMessage(), ex2); + throw new CheckstyleException(exceptionMessage.getMessage(), ex); } } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java b/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java index fb0c79883..f70242a53 100755 --- a/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java @@ -482,8 +482,8 @@ public final class TreeWalker try { cache.persist(); } - catch (IOException e) { - throw new IllegalStateException("Unable to persist cache file", e); + catch (IOException ex) { + throw new IllegalStateException("Unable to persist cache file", ex); } } super.destroy(); diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java b/src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java index a0cc5c93d..77bdd4de1 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java @@ -364,8 +364,8 @@ public class CheckstyleAntTask extends Task { log("To process the files took " + (processingEndTime - processingStartTime) + TIME_SUFFIX, Project.MSG_VERBOSE); } - catch (CheckstyleException e) { - throw new BuildException("Unable to process files: " + files, e); + catch (CheckstyleException ex) { + throw new BuildException("Unable to process files: " + files, ex); } final int numWarnings = warningCounter.getCount(); final boolean okStatus = numErrs <= maxErrors && numWarnings <= maxWarnings; @@ -412,9 +412,9 @@ public class CheckstyleAntTask extends Task { checker.contextualize(context); checker.configure(config); } - catch (final CheckstyleException e) { + catch (final CheckstyleException ex) { throw new BuildException(String.format(Locale.ROOT, "Unable to create a Checker: " - + "configLocation {%s}, classpath {%s}.", configLocation, classpath), e); + + "configLocation {%s}, classpath {%s}.", configLocation, classpath), ex); } return checker; } @@ -435,9 +435,9 @@ public class CheckstyleAntTask extends Task { inStream = new FileInputStream(properties); returnValue.load(inStream); } - catch (final IOException e) { + catch (final IOException ex) { throw new BuildException("Error loading Properties file '" - + properties + "'", e, getLocation()); + + properties + "'", ex, getLocation()); } finally { Closeables.closeQuietly(inStream); @@ -482,9 +482,9 @@ public class CheckstyleAntTask extends Task { } } } - catch (IOException e) { + catch (IOException ex) { throw new BuildException(String.format(Locale.ROOT, "Unable to create listeners: " - + "formatters {%s}.", formatters), e); + + "formatters {%s}.", formatters), ex); } return listeners; } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/AutomaticBean.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/AutomaticBean.java index e37223b83..0bcb13435 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/AutomaticBean.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/AutomaticBean.java @@ -169,19 +169,19 @@ public class AutomaticBean beanUtils.copyProperty(this, key, value); } catch (final InvocationTargetException | IllegalAccessException - | NoSuchMethodException e) { + | NoSuchMethodException ex) { // There is no way to catch IllegalAccessException | NoSuchMethodException // as we do PropertyUtils.getPropertyDescriptor before beanUtils.copyProperty // so we have to join these exceptions with InvocationTargetException // to satisfy UTs coverage final String message = String.format(Locale.ROOT, "Cannot set property '%s' to '%s' in module %s", key, value, moduleName); - throw new CheckstyleException(message, e); + throw new CheckstyleException(message, ex); } - catch (final IllegalArgumentException | ConversionException e) { + catch (final IllegalArgumentException | ConversionException ex) { final String message = String.format(Locale.ROOT, "illegal value '%s' for property " + "'%s' of module %s", value, key, moduleName); - throw new CheckstyleException(message, e); + throw new CheckstyleException(message, ex); } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractFormatCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractFormatCheck.java index 7e7795520..1e0cf5489 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractFormatCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractFormatCheck.java @@ -111,8 +111,8 @@ public abstract class AbstractFormatCheck format = regexpFormat; compileFlags |= compileFlagsParam; } - catch (final PatternSyntaxException e) { - throw new ConversionException("unable to parse " + regexpFormat, e); + catch (final PatternSyntaxException ex) { + throw new ConversionException("unable to parse " + regexpFormat, ex); } } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheck.java index 0805d0690..3610f4fcc 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheck.java @@ -390,8 +390,8 @@ public class TranslationCheck keys.add(element.nextElement()); } } - catch (final IOException e) { - logIoException(e, file); + catch (final IOException ex) { + logIoException(ex, file); } finally { Closeables.closeQuietly(inStream); diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java index 2d6cfb9a2..78a5ba7af 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java @@ -76,9 +76,9 @@ public class UniquePropertiesCheck extends AbstractFileSetCheck { fileInputStream.close(); } } - catch (IOException e) { + catch (IOException ex) { log(0, IO_EXCEPTION_KEY, file.getPath(), - e.getLocalizedMessage()); + ex.getLocalizedMessage()); } for (Entry duplication : properties diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheck.java index 825d28bd7..ebd132854 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheck.java @@ -88,7 +88,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtils; * {@code * try { * throw new RuntimeException(); - * } catch (RuntimeException e) { + * } catch (RuntimeException ex) { * //This is expected * } * } @@ -110,7 +110,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtils; * {@code * try { * throw new RuntimeException(); - * } catch (RuntimeException e) { + * } catch (RuntimeException ex) { * //This is expected * } * } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java index a85fc15ee..d47887c6d 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java @@ -147,11 +147,11 @@ final class ImportControlLoader extends AbstractLoader { try { inputStream = uri.toURL().openStream(); } - catch (final MalformedURLException e) { - throw new CheckstyleException("syntax error in url " + uri, e); + catch (final MalformedURLException ex) { + throw new CheckstyleException("syntax error in url " + uri, ex); } - catch (final IOException e) { - throw new CheckstyleException("unable to find " + uri, e); + catch (final IOException ex) { + throw new CheckstyleException("unable to find " + uri, ex); } final InputSource source = new InputSource(inputStream); return load(source, uri); @@ -171,12 +171,12 @@ final class ImportControlLoader extends AbstractLoader { loader.parseInputSource(source); return loader.getRoot(); } - catch (final ParserConfigurationException | SAXException e) { + catch (final ParserConfigurationException | SAXException ex) { throw new CheckstyleException("unable to parse " + uri - + " - " + e.getMessage(), e); + + " - " + ex.getMessage(), ex); } - catch (final IOException e) { - throw new CheckstyleException("unable to read " + uri, e); + catch (final IOException ex) { + throw new CheckstyleException("unable to read " + uri, ex); } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck.java index 8ea27cf51..c0db620c6 100755 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck.java @@ -233,7 +233,7 @@ public abstract class AbstractJavadocCheck extends Check { final DetailNode tree = convertParseTreeToDetailNode(parseTree); result.setTree(tree); } - catch (ParseCancellationException e) { + catch (ParseCancellationException ex) { // If syntax error occurs then message is printed by error listener // and parser throws this runtime exception to stop parsing. // Just stop processing current Javadoc comment. @@ -243,7 +243,7 @@ public abstract class AbstractJavadocCheck extends Check { if (parseErrorMessage == null) { parseErrorMessage = new ParseErrorMessage(javadocCommentAst.getLineNo(), UNRECOGNIZED_ANTLR_ERROR_MESSAGE_KEY, - javadocCommentAst.getColumnNo(), e.getMessage()); + javadocCommentAst.getColumnNo(), ex.getMessage()); } result.setParseErrorMessage(parseErrorMessage); diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java index bc98d509f..8ea813643 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java @@ -62,7 +62,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtils; *
  *   try {
  *     thirdPartyLibrary.method();
- *   } catch (RuntimeException e) {
+ *   } catch (RuntimeException ex) {
  *     // ALLOW ILLEGAL CATCH BECAUSE third party API wraps everything
  *     // in RuntimeExceptions.
  *     ...
@@ -340,10 +340,10 @@ public class SuppressWithNearbyCommentFilter
                     }
                     influence = Integer.parseInt(format);
                 }
-                catch (final NumberFormatException e) {
+                catch (final NumberFormatException ex) {
                     throw new ConversionException(
                         "unable to parse influence from '" + text
-                            + "' using " + filter.influenceFormat, e);
+                            + "' using " + filter.influenceFormat, ex);
                 }
                 if (influence >= 0) {
                     firstLine = line;
@@ -354,10 +354,10 @@ public class SuppressWithNearbyCommentFilter
                     lastLine = line;
                 }
             }
-            catch (final PatternSyntaxException e) {
+            catch (final PatternSyntaxException ex) {
                 throw new ConversionException(
                     "unable to parse expanded comment " + format,
-                    e);
+                    ex);
             }
         }
 
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java
index ccceba8de..2c95ac1a4 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java
@@ -363,10 +363,10 @@ public class SuppressionCommentFilter
                     }
                 }
             }
-            catch (final PatternSyntaxException e) {
+            catch (final PatternSyntaxException ex) {
                 throw new ConversionException(
                     "unable to parse expanded comment " + format,
-                    e);
+                    ex);
             }
         }
 
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoader.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoader.java
index 1a5450f56..e99d9dac5 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoader.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoader.java
@@ -144,21 +144,21 @@ public final class SuppressionsLoader
             suppressionsLoader.parseInputSource(source);
             return suppressionsLoader.filterChain;
         }
-        catch (final FileNotFoundException e) {
-            throw new CheckstyleException(UNABLE_TO_FIND_ERROR_MESSAGE + sourceName, e);
+        catch (final FileNotFoundException ex) {
+            throw new CheckstyleException(UNABLE_TO_FIND_ERROR_MESSAGE + sourceName, ex);
         }
-        catch (final ParserConfigurationException | SAXException e) {
+        catch (final ParserConfigurationException | SAXException ex) {
             final String message = String.format(Locale.ROOT, "Unable to parse %s - %s",
-                    sourceName, e.getMessage());
-            throw new CheckstyleException(message, e);
+                    sourceName, ex.getMessage());
+            throw new CheckstyleException(message, ex);
         }
-        catch (final IOException e) {
-            throw new CheckstyleException("Unable to read " + sourceName, e);
+        catch (final IOException ex) {
+            throw new CheckstyleException("Unable to read " + sourceName, ex);
         }
-        catch (final NumberFormatException e) {
+        catch (final NumberFormatException ex) {
             final String message = String.format(Locale.ROOT, "Number format exception %s - %s",
-                    sourceName, e.getMessage());
-            throw new CheckstyleException(message, e);
+                    sourceName, ex.getMessage());
+            throw new CheckstyleException(message, ex);
         }
     }
 
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtils.java b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtils.java
index 827a62dad..44bb5c175 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtils.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtils.java
@@ -202,9 +202,9 @@ public final class CommonUtils {
         try {
             return Pattern.compile(pattern, flags);
         }
-        catch (final PatternSyntaxException e) {
+        catch (final PatternSyntaxException ex) {
             throw new ConversionException(
-                    "Failed to initialise regular expression " + pattern, e);
+                    "Failed to initialise regular expression " + pattern, ex);
         }
     }
 
@@ -333,8 +333,8 @@ public final class CommonUtils {
         try {
             closeable.close();
         }
-        catch (IOException e) {
-            throw new IllegalStateException("Cannot close the stream", e);
+        catch (IOException ex) {
+            throw new IllegalStateException("Cannot close the stream", ex);
         }
     }
 
@@ -370,8 +370,8 @@ public final class CommonUtils {
                     }
                     uri = configUrl.toURI();
                 }
-                catch (final URISyntaxException e) {
-                    throw new CheckstyleException(UNABLE_TO_FIND_EXCEPTION_PREFIX + filename, e);
+                catch (final URISyntaxException ex) {
+                    throw new CheckstyleException(UNABLE_TO_FIND_EXCEPTION_PREFIX + filename, ex);
                 }
             }
         }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java
index 00741d201..756e540d9 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java
@@ -269,7 +269,7 @@ public class BaseCheckTestSupport {
         try {
             pr.load(getClass().getResourceAsStream("messages.properties"));
         }
-        catch (IOException e) {
+        catch (IOException ex) {
             return null;
         }
         final MessageFormat formatter = new MessageFormat(pr.getProperty(messageKey),
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java
index e26820e03..f7d27b729 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java
@@ -193,7 +193,7 @@ public class CommitValidationTest {
                     new RevCommitsPair(new OmitMergeCommitsIterator(first),
                             new OmitMergeCommitsIterator(second));
         }
-        catch (GitAPIException | IOException e) {
+        catch (GitAPIException | IOException ex) {
             revCommitIteratorPair = new RevCommitsPair();
         }
 
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java
index 0529e5624..b7b33e22e 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java
@@ -381,9 +381,9 @@ public class ConfigurationLoaderTest {
             fail("Exception is expected");
 
         }
-        catch (InvocationTargetException e) {
-            assertTrue(e.getCause() instanceof IllegalStateException);
-            assertEquals("Unknown name:" + "hello" + ".", e.getCause().getMessage());
+        catch (InvocationTargetException ex) {
+            assertTrue(ex.getCause() instanceof IllegalStateException);
+            assertEquals("Unknown name:" + "hello" + ".", ex.getCause().getMessage());
         }
     }
 
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java
index 3a60742f2..0b4b4b97c 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java
@@ -453,14 +453,14 @@ public class MainTest {
             }
             fail("Exception was expected");
         }
-        catch (InvocationTargetException e) {
-            assertTrue(e.getCause() instanceof CheckstyleException);
+        catch (InvocationTargetException ex) {
+            assertTrue(ex.getCause() instanceof CheckstyleException);
             // We do separate validation for message as in Windows
             // disk drive letter appear in message,
             // so we skip that drive letter for compatibility issues
-            assertTrue(e.getCause().getMessage()
+            assertTrue(ex.getCause().getMessage()
                     .startsWith("Unable to load properties from file '"));
-            assertTrue(e.getCause().getMessage().endsWith(":invalid'."));
+            assertTrue(ex.getCause().getMessage().endsWith(":invalid'."));
         }
     }
 
@@ -473,9 +473,9 @@ public class MainTest {
             method.invoke(null, "myformat", null);
             fail();
         }
-        catch (InvocationTargetException e) {
-            assertTrue(e.getCause() instanceof IllegalStateException);
-            assertTrue(e.getCause().getMessage().startsWith("Invalid output format. Found"));
+        catch (InvocationTargetException ex) {
+            assertTrue(ex.getCause() instanceof IllegalStateException);
+            assertTrue(ex.getCause().getMessage().startsWith("Invalid output format. Found"));
         }
     }
 
@@ -489,9 +489,9 @@ public class MainTest {
             method.invoke(null, "myformat", outDir);
             fail();
         }
-        catch (InvocationTargetException e) {
-            assertTrue(e.getCause() instanceof IllegalStateException);
-            assertTrue(e.getCause().getMessage().startsWith("Invalid output format. Found"));
+        catch (InvocationTargetException ex) {
+            assertTrue(ex.getCause() instanceof IllegalStateException);
+            assertTrue(ex.getCause().getMessage().startsWith("Invalid output format. Found"));
         }
         finally {
             // method creates output folder
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/PropertyCacheFileTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/PropertyCacheFileTest.java
index 236a9a329..73f964516 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/PropertyCacheFileTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/PropertyCacheFileTest.java
@@ -109,9 +109,9 @@ public class PropertyCacheFileTest {
             method.invoke(cache, config);
             fail();
         }
-        catch (InvocationTargetException e) {
-            assertTrue(e.getCause().getCause() instanceof NoSuchAlgorithmException);
-            assertEquals("Unable to calculate hashcode.", e.getCause().getMessage());
+        catch (InvocationTargetException ex) {
+            assertTrue(ex.getCause().getCause() instanceof NoSuchAlgorithmException);
+            assertEquals("Unable to calculate hashcode.", ex.getCause().getMessage());
         }
     }
 }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
index dcde375ac..5664aff99 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
@@ -93,8 +93,8 @@ public class TreeWalkerTest extends BaseCheckTestSupport {
             verify(checkConfig, getPath("InputMain.java"), expected);
             fail();
         }
-        catch (CheckstyleException e) {
-            final String errorMsg = e.getMessage();
+        catch (CheckstyleException ex) {
+            final String errorMsg = ex.getMessage();
             assertTrue(errorMsg.contains("cannot initialize module"
                     + " com.puppycrawl.tools.checkstyle.TreeWalker - Token \"IMPORT\""
                     + " was not found in Acceptable tokens list in check"
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java
index a43655a88..1cefb8cb5 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java
@@ -222,8 +222,8 @@ public class XDocsPagesTest {
 
             return builder.parse(new InputSource(new StringReader(code)));
         }
-        catch (IOException | SAXException e) {
-            Assert.fail(fileName + " has invalid xml (" + e.getMessage() + "): "
+        catch (IOException | SAXException ex) {
+            Assert.fail(fileName + " has invalid xml (" + ex.getMessage() + "): "
                     + unserializedSource);
         }
 
@@ -261,8 +261,8 @@ public class XDocsPagesTest {
                 checker.destroy();
             }
         }
-        catch (CheckstyleException e) {
-            Assert.fail(fileName + " has invalid Checkstyle xml (" + e.getMessage() + "): "
+        catch (CheckstyleException ex) {
+            Assert.fail(fileName + " has invalid Checkstyle xml (" + ex.getMessage() + "): "
                     + unserializedSource);
         }
     }
@@ -320,7 +320,7 @@ public class XDocsPagesTest {
         try {
             instance = moduleFactory.createModule(sectionName);
         }
-        catch (CheckstyleException e) {
+        catch (CheckstyleException ex) {
             Assert.fail(fileName + " couldn't find class: " + sectionName);
         }
 
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/api/FileTextTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/api/FileTextTest.java
index 8ba76371d..0d64a9015 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/api/FileTextTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/FileTextTest.java
@@ -37,8 +37,8 @@ public class FileTextTest {
             new FileText(new File("any name"), charsetName);
             fail();
         }
-        catch (UnsupportedEncodingException e) {
-            assertEquals("Unsupported charset: " + charsetName, e.getMessage());
+        catch (UnsupportedEncodingException ex) {
+            assertEquals("Unsupported charset: " + charsetName, ex.getMessage());
         }
 
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/ClassResolverTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/ClassResolverTest.java
index facc7a034..7ab2097c6 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/ClassResolverTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/ClassResolverTest.java
@@ -52,7 +52,7 @@ public class ClassResolverTest {
             classResolver.resolve("who.will.win.the.world.cup", "");
             fail("Should not resolve class");
         }
-        catch (ClassNotFoundException e) {
+        catch (ClassNotFoundException ex) {
             // expected
         }
         classResolver.resolve("java.lang.String", "");
@@ -63,7 +63,7 @@ public class ClassResolverTest {
             classResolver.resolve("ChoiceFormat", "");
             fail();
         }
-        catch (ClassNotFoundException e) {
+        catch (ClassNotFoundException ex) {
             // expected
         }
 
@@ -79,7 +79,7 @@ public class ClassResolverTest {
             javaUtilClassResolver.resolve("two.nil.england", "");
             fail();
         }
-        catch (ClassNotFoundException e) {
+        catch (ClassNotFoundException ex) {
             // expected
         }
     }
@@ -96,9 +96,9 @@ public class ClassResolverTest {
             classResolver.resolve("someClass", "");
             fail("Exception expected");
         }
-        catch (ClassNotFoundException e) {
+        catch (ClassNotFoundException ex) {
             // expected
-            assertEquals("someClass", e.getMessage());
+            assertEquals("someClass", ex.getMessage());
         }
     }
 
@@ -144,10 +144,10 @@ public class ClassResolverTest {
             classResolver.resolve("someClass", "");
             fail("Exception expected");
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // expected
-            assertTrue(e.getCause() instanceof ClassNotFoundException);
-            assertTrue(e.getMessage().endsWith("expected exception"));
+            assertTrue(ex.getCause() instanceof ClassNotFoundException);
+            assertTrue(ex.getMessage().endsWith("expected exception"));
         }
     }
 }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java
index ee3bec32c..c98584f1f 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java
@@ -180,7 +180,7 @@ public class FinalLocalVariableCheckTest
             check.visitToken(lambdaAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java
index 5ff235f3e..87e419227 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java
@@ -185,7 +185,7 @@ public class IllegalInstantiationCheckTest
             check.visitToken(lambdaAst);
             Assert.fail();
         }
-        catch (IllegalArgumentException e) {
+        catch (IllegalArgumentException ex) {
             // it is OK
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java
index 76a3859b1..c0395bcfb 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java
@@ -212,7 +212,7 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport {
             check.visitToken(classDefAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java
index 7e81de72e..80fa0d076 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java
@@ -100,7 +100,7 @@ public class ModifiedControlVariableCheckTest
             check.visitToken(classDefAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
 
@@ -108,7 +108,7 @@ public class ModifiedControlVariableCheckTest
             check.leaveToken(classDefAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java
index 4ecae943a..ad318661e 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java
@@ -73,7 +73,7 @@ public class ParameterAssignmentCheckTest extends BaseCheckTestSupport {
             check.visitToken(classDefAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
 
@@ -81,7 +81,7 @@ public class ParameterAssignmentCheckTest extends BaseCheckTestSupport {
             check.leaveToken(classDefAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java
index 3ed91e2fe..e6df18746 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java
@@ -126,7 +126,7 @@ public class ReturnCountCheckTest extends BaseCheckTestSupport {
             check.visitToken(classDefAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
 
@@ -134,7 +134,7 @@ public class ReturnCountCheckTest extends BaseCheckTestSupport {
             check.leaveToken(classDefAst);
             Assert.fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             // it is OK
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java
index 30f758129..dffba0c27 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java
@@ -101,7 +101,7 @@ public class MutableExceptionCheckTest extends BaseCheckTestSupport {
             obj.visitToken(ast);
             fail();
         }
-        catch (IllegalStateException e) {
+        catch (IllegalStateException ex) {
             //expected
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java
index d0b7381e1..953a20531 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java
@@ -92,8 +92,8 @@ public class ThrowsCountCheckTest extends BaseCheckTestSupport {
             obj.visitToken(ast);
             fail();
         }
-        catch (IllegalStateException e) {
-            assertEquals(ast.toString(), e.getMessage());
+        catch (IllegalStateException ex) {
+            assertEquals(ast.toString(), ex.getMessage());
         }
     }
 
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java
index 92e7c0fd6..300fc3b70 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java
@@ -78,8 +78,8 @@ public class ImportControlLoaderTest {
             privateMethod.invoke(null, attr, "you_cannot_find_me");
         }
         catch (IllegalAccessException | IllegalArgumentException
-                | NoSuchMethodException | SecurityException e) {
-            throw new IllegalStateException(e);
+                | NoSuchMethodException | SecurityException ex) {
+            throw new IllegalStateException(ex);
         }
     }
 
@@ -98,8 +98,8 @@ public class ImportControlLoaderTest {
                     new File(getPath("import-control_complete.xml")).toURI());
         }
         catch (IllegalAccessException | IllegalArgumentException
-                | NoSuchMethodException | SecurityException e) {
-            throw new IllegalStateException(e);
+                | NoSuchMethodException | SecurityException ex) {
+            throw new IllegalStateException(ex);
         }
     }
 }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckTest.java
index e5a7b45c0..f98025310 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckTest.java
@@ -195,8 +195,8 @@ public class CommentsIndentationCheckTest extends BaseCheckTestSupport {
             check.visitToken(methodDef);
             Assert.fail("IllegalArgumentException should have been thrown!");
         }
-        catch (IllegalArgumentException e) {
-            final String msg = e.getMessage();
+        catch (IllegalArgumentException ex) {
+            final String msg = ex.getMessage();
             Assert.assertEquals("Unexpected token type: methodStub", msg);
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java
index 57dd015bd..e526d23c1 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java
@@ -204,8 +204,8 @@ public class NoWhitespaceAfterCheckTest
             check.visitToken(astArrayDeclarator);
             fail("no intended exception thrown");
         }
-        catch (IllegalStateException e) {
-            assertEquals("unexpected ast syntaximport[0x-1]", e.getMessage());
+        catch (IllegalStateException ex) {
+            assertEquals("unexpected ast syntaximport[0x-1]", ex.getMessage());
         }
     }
 
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java
index 7114c5944..87a057bb1 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java
@@ -198,7 +198,7 @@ public class SuppressionsLoaderTest extends BaseCheckTestSupport {
             final HttpURLConnection urlConnect = (HttpURLConnection) verifiableUrl.openConnection();
             urlConnect.getContent();
         }
-        catch (IOException e) {
+        catch (IOException ex) {
             return false;
         }
         return true;
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java
index d95519938..b7fcbcaef 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java
@@ -287,7 +287,7 @@ public class JavadocParseTreeTest {
         public void syntaxError(
                 Recognizer recognizer, Object offendingSymbol,
                 int line, int charPositionInLine,
-                String msg, RecognitionException e) {
+                String msg, RecognitionException ex) {
             Assert.fail("[" + line + ", " + charPositionInLine + "] " + msg);
         }
     }
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/utils/TokenUtilsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/utils/TokenUtilsTest.java
index 9cd7744be..47deab91c 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/TokenUtilsTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/TokenUtilsTest.java
@@ -103,7 +103,7 @@ public class TokenUtilsTest {
             assertEquals("given id " + id, expected.getMessage());
 
         }
-        catch (IllegalAccessException | NoSuchFieldException e) {
+        catch (IllegalAccessException | NoSuchFieldException ex) {
             fail();
         }
     }