forked from phoedos/pmd
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
This commit is contained in:
@ -9,7 +9,6 @@ import java.util.List;
|
|||||||
import net.sourceforge.pmd.AbstractJavaRule;
|
import net.sourceforge.pmd.AbstractJavaRule;
|
||||||
import net.sourceforge.pmd.ast.ASTAssignmentOperator;
|
import net.sourceforge.pmd.ast.ASTAssignmentOperator;
|
||||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
|
import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
|
||||||
import net.sourceforge.pmd.ast.ASTCompilationUnit;
|
|
||||||
import net.sourceforge.pmd.ast.ASTFieldDeclaration;
|
import net.sourceforge.pmd.ast.ASTFieldDeclaration;
|
||||||
import net.sourceforge.pmd.ast.ASTIfStatement;
|
import net.sourceforge.pmd.ast.ASTIfStatement;
|
||||||
import net.sourceforge.pmd.ast.ASTLiteral;
|
import net.sourceforge.pmd.ast.ASTLiteral;
|
||||||
@ -47,17 +46,7 @@ import net.sourceforge.pmd.ast.Node;
|
|||||||
*/
|
*/
|
||||||
public class DoubleCheckedLocking extends AbstractJavaRule {
|
public class DoubleCheckedLocking extends AbstractJavaRule {
|
||||||
|
|
||||||
private List<String> volatileFields;
|
private List<String> volatileFields = new ArrayList<String>(0);
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object visit(ASTCompilationUnit compilationUnit, Object data) {
|
|
||||||
if ( volatileFields == null ) {
|
|
||||||
volatileFields = new ArrayList<String>(0);
|
|
||||||
} else {
|
|
||||||
volatileFields.clear();
|
|
||||||
}
|
|
||||||
return super.visit(compilationUnit, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||||
@ -70,8 +59,7 @@ public class DoubleCheckedLocking extends AbstractJavaRule {
|
|||||||
@Override
|
@Override
|
||||||
public Object visit(ASTFieldDeclaration fieldDeclaration, Object data) {
|
public Object visit(ASTFieldDeclaration fieldDeclaration, Object data) {
|
||||||
if ( fieldDeclaration.isVolatile() ) {
|
if ( fieldDeclaration.isVolatile() ) {
|
||||||
List<ASTVariableDeclaratorId> declarators = fieldDeclaration.findChildrenOfType(ASTVariableDeclaratorId.class);
|
for (ASTVariableDeclaratorId declarator : fieldDeclaration.findChildrenOfType(ASTVariableDeclaratorId.class) ) {
|
||||||
for (ASTVariableDeclaratorId declarator : declarators ) {
|
|
||||||
this.volatileFields.add(declarator.getImage());
|
this.volatileFields.add(declarator.getImage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user