forked from phoedos/pmd
Allow concurrency in AttributeAxisIterator
This commit is contained in:
Juan Martín Sotuyo Dodero
committed by
Andreas Dangel
parent
b5ca7baa9a
commit
49e3de4a06
@ -5,11 +5,10 @@ package net.sourceforge.pmd.lang.ast.xpath;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
|
||||
@ -49,8 +48,8 @@ public class AttributeAxisIterator implements Iterator<Attribute> {
|
||||
private int position;
|
||||
private Node node;
|
||||
|
||||
private static Map<Class<?>, MethodWrapper[]> methodCache =
|
||||
Collections.synchronizedMap(new HashMap<Class<?>, MethodWrapper[]>());
|
||||
private static ConcurrentMap<Class<?>, MethodWrapper[]> methodCache =
|
||||
new ConcurrentHashMap<Class<?>, MethodWrapper[]>();
|
||||
|
||||
public AttributeAxisIterator(Node contextNode) {
|
||||
this.node = contextNode;
|
||||
@ -62,7 +61,7 @@ public class AttributeAxisIterator implements Iterator<Attribute> {
|
||||
postFilter.add(new MethodWrapper(element));
|
||||
}
|
||||
}
|
||||
methodCache.put(contextNode.getClass(), postFilter.toArray(new MethodWrapper[postFilter.size()]));
|
||||
methodCache.putIfAbsent(contextNode.getClass(), postFilter.toArray(new MethodWrapper[postFilter.size()]));
|
||||
}
|
||||
this.methodWrappers = methodCache.get(contextNode.getClass());
|
||||
|
||||
|
Reference in New Issue
Block a user