forked from phoedos/pmd
Fix NullPointerException in ClassScope.qualifyTypeName()
This commit is contained in:
@ -307,6 +307,9 @@ public class ClassScope extends AbstractJavaScope {
|
||||
}
|
||||
|
||||
private String qualifyTypeName(String typeImage) {
|
||||
if (typeImage == null) {
|
||||
return null;
|
||||
}
|
||||
for (String qualified : this.getEnclosingScope(SourceFileScope.class).getQualifiedTypeNames().keySet()) {
|
||||
int fullLength = qualified.length();
|
||||
int nameLength = typeImage.length();
|
||||
|
@ -269,6 +269,11 @@ public class ClassScopeTest extends STBBaseTst {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullType() {
|
||||
parseCode(TEST_NULL_TYPE);
|
||||
}
|
||||
|
||||
private static final String NESTED_CLASS_FIELD_AND_PARAM =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" class Test {" + PMD.EOL +
|
||||
@ -376,6 +381,12 @@ public class ClassScopeTest extends STBBaseTst {
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static final String TEST_NULL_TYPE =
|
||||
"public abstract class NullTypeTest {" + PMD.EOL +
|
||||
" protected Comparator<TreeNode> nodesComparator = (o1, o2) -> StringHelper.saveCompare(getFilterableString(o1), getFilterableString(o2));" + PMD.EOL +
|
||||
" public abstract String getFilterableString(TreeNode node);" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
public static junit.framework.Test suite() {
|
||||
return new junit.framework.JUnit4TestAdapter(ClassScopeTest.class);
|
||||
}
|
||||
|
Reference in New Issue
Block a user