From 8b4ade30165bedaa0900fb59273fff615258c198 Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Sat, 15 Aug 2009 18:05:52 +0000 Subject: [PATCH] While debugging I realise that PMD rules are 'stateless', so I remove my code to clean the ArrayList at each passage. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6985 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/rules/DoubleCheckedLocking.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/rules/DoubleCheckedLocking.java b/pmd/src/net/sourceforge/pmd/rules/DoubleCheckedLocking.java index 9698430ee8..a9c5c8f051 100644 --- a/pmd/src/net/sourceforge/pmd/rules/DoubleCheckedLocking.java +++ b/pmd/src/net/sourceforge/pmd/rules/DoubleCheckedLocking.java @@ -9,7 +9,6 @@ import java.util.List; import net.sourceforge.pmd.AbstractJavaRule; import net.sourceforge.pmd.ast.ASTAssignmentOperator; import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration; -import net.sourceforge.pmd.ast.ASTCompilationUnit; import net.sourceforge.pmd.ast.ASTFieldDeclaration; import net.sourceforge.pmd.ast.ASTIfStatement; import net.sourceforge.pmd.ast.ASTLiteral; @@ -47,17 +46,7 @@ import net.sourceforge.pmd.ast.Node; */ public class DoubleCheckedLocking extends AbstractJavaRule { - private List volatileFields; - - @Override - public Object visit(ASTCompilationUnit compilationUnit, Object data) { - if ( volatileFields == null ) { - volatileFields = new ArrayList(0); - } else { - volatileFields.clear(); - } - return super.visit(compilationUnit, data); - } + private List volatileFields = new ArrayList(0); @Override public Object visit(ASTClassOrInterfaceDeclaration node, Object data) { @@ -70,8 +59,7 @@ public class DoubleCheckedLocking extends AbstractJavaRule { @Override public Object visit(ASTFieldDeclaration fieldDeclaration, Object data) { if ( fieldDeclaration.isVolatile() ) { - List declarators = fieldDeclaration.findChildrenOfType(ASTVariableDeclaratorId.class); - for (ASTVariableDeclaratorId declarator : declarators ) { + for (ASTVariableDeclaratorId declarator : fieldDeclaration.findChildrenOfType(ASTVariableDeclaratorId.class) ) { this.volatileFields.add(declarator.getImage()); } }