diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index b2830a2420..0242b5a7ca 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -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: diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/loggingjava/xml/MoreThanOneLogger.xml b/pmd/regress/test/net/sourceforge/pmd/rules/loggingjava/xml/MoreThanOneLogger.xml index c30252f1e8..5e50b87a11 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/loggingjava/xml/MoreThanOneLogger.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/loggingjava/xml/MoreThanOneLogger.xml @@ -37,6 +37,17 @@ public class Foo { class Bar { Logger log2; } +} + ]]> + + + + 0 + diff --git a/pmd/src/net/sourceforge/pmd/rules/MoreThanOneLogger.java b/pmd/src/net/sourceforge/pmd/rules/MoreThanOneLogger.java index 820e06fa21..019f98f259 100644 --- a/pmd/src/net/sourceforge/pmd/rules/MoreThanOneLogger.java +++ b/pmd/src/net/sourceforge/pmd/rules/MoreThanOneLogger.java @@ -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;