Fix NPE on custom exceptions

This commit is contained in:
Jeff Hube
2019-05-10 12:16:30 -04:00
parent c5b0c8c17a
commit 000e32b2ee
2 changed files with 13 additions and 0 deletions

View File

@ -31,6 +31,11 @@ public class FormalParameterRegexNamingConventionsRule extends AbstractRegexNami
@Override
public Object visit(ASTParameter node, Object data) {
// classes that extend Exception will contains methods that have parameters with null names
if (node.getImage() == null) {
return data;
}
if (node.getModifiers().isFinal()) {
checkMatches(FINAL_METHOD_PARAMETER_REGEX, node, data);
} else {

View File

@ -57,4 +57,12 @@ public class Foo {
]]></code>
</test-code>
<test-code>
<description>ignores null parameter names</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public with sharing class MyException extends Exception { }
]]></code>
</test-code>
</test-data>