Fix PMD violations of AvoidCatchingGenericException rule. #959
This commit is contained in:
parent
1b5c3936f5
commit
4ea1896f46
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
<!-- The local ones -->
|
||||
<allow class="java.security.MessageDigest" local-only="true"/>
|
||||
<allow class="java.security.NoSuchAlgorithmException" local-only="true"/>
|
||||
<allow pkg="com.puppycrawl.tools.checkstyle.grammars" local-only="true"/>
|
||||
<allow pkg="org.apache.commons.cli" local-only="true"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -223,11 +223,15 @@
|
|||
<exclude name="UseStringBufferForStringAppends"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/strictexception.xml">
|
||||
<!-- till #959 -->
|
||||
<exclude name="AvoidCatchingGenericException"/>
|
||||
<!-- till #961 -->
|
||||
<exclude name="AvoidThrowingRawExceptionTypes"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/strictexception.xml/AvoidCatchingGenericException">
|
||||
<properties>
|
||||
<!-- till #1244 and #1245 -->
|
||||
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='Checker' or @Image='CheckstyleAntTask']"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/strictexception.xml/ExceptionAsFlowControl">
|
||||
<properties>
|
||||
<!-- till #1159 -->
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Properties;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
|
|
@ -202,9 +203,9 @@ final class PropertyCacheFile {
|
|||
|
||||
return hexEncode(md.digest());
|
||||
}
|
||||
catch (final Exception ex) { // IO, NoSuchAlgorithm
|
||||
LOG.debug("Unable to calculate hashcode.", ex);
|
||||
return "ALWAYS FRESH: " + System.currentTimeMillis();
|
||||
catch (final IOException | NoSuchAlgorithmException ex) {
|
||||
// rethrow as unchecked exception
|
||||
throw new IllegalStateException("Unable to calculate hashcode.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ public class RightCurlyCheck extends AbstractOptionCheck<RightCurlyOption> {
|
|||
nextToken = ast;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected token type ("
|
||||
throw new IllegalStateException("Unexpected token type ("
|
||||
+ Utils.getTokenName(ast.getType()) + ")");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ public class CustomImportOrderCheck extends Check {
|
|||
try {
|
||||
samePackageMatchingDepth = Integer.parseInt(rule);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (NumberFormatException e) {
|
||||
samePackageDomainsRegExp = rule;
|
||||
}
|
||||
customImportOrderRules.add(SAME_PACKAGE_RULE_GROUP);
|
||||
|
|
|
|||
|
|
@ -77,9 +77,10 @@ public final class JavadocUtils {
|
|||
tempTokenValueToName[tokenValue] = name;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (IllegalAccessException ex) {
|
||||
// rethrow as unchecked exception
|
||||
throw new IllegalStateException(
|
||||
"Failed to instantiate collection of Javadoc tokens", e);
|
||||
"Failed to instantiate collection of Javadoc tokens", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue