Bug fix: NPE in MoreThanOneLogger

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6073 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch 2008-04-28 18:34:24 +00:00
parent 411cf2826f
commit 713dc2a9a5
3 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,7 @@
Fixed false positive in UnusedImports: javadoc comments are parsed to check @see and other tags
Fixed parsing bug: constant fields in annotation classes
Bug fix: NPE in MoreThanOneLogger
April 11, 2008 - 4.2.1:

View File

@ -37,6 +37,17 @@ public class Foo {
class Bar {
Logger log2;
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
ok, fixing NPE bug
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public @interface Foo {
String FOO = "foo";
}
]]></code>
</test-code>

View File

@ -3,6 +3,7 @@ package net.sourceforge.pmd.rules;
import java.util.Stack;
import net.sourceforge.pmd.AbstractRule;
import net.sourceforge.pmd.ast.ASTAnnotationTypeDeclaration;
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
import net.sourceforge.pmd.ast.ASTEnumDeclaration;
@ -44,6 +45,10 @@ public class MoreThanOneLogger extends AbstractRule {
return init (node, data);
}
public Object visit(ASTAnnotationTypeDeclaration node, Object data) {
return init (node, data);
}
private Object init(SimpleJavaNode node, Object data) {
stack.push(count);
count = NumericConstants.ZERO;