提交 7720e763 编写于 作者: M mullan

Merge

...@@ -70,10 +70,13 @@ public class IdResolver { ...@@ -70,10 +70,13 @@ public class IdResolver {
*/ */
public static void registerElementById(Element element, String idValue) { public static void registerElementById(Element element, String idValue) {
Document doc = element.getOwnerDocument(); Document doc = element.getOwnerDocument();
WeakHashMap elementMap = (WeakHashMap) docMap.get(doc); WeakHashMap elementMap;
if(elementMap == null) { synchronized (docMap) {
elementMap = new WeakHashMap(); elementMap = (WeakHashMap) docMap.get(doc);
docMap.put(doc, elementMap); if (elementMap == null) {
elementMap = new WeakHashMap();
docMap.put(doc, elementMap);
}
} }
elementMap.put(idValue, new WeakReference(element)); elementMap.put(idValue, new WeakReference(element));
} }
...@@ -153,7 +156,10 @@ public class IdResolver { ...@@ -153,7 +156,10 @@ public class IdResolver {
private static Element getElementByIdType(Document doc, String id) { private static Element getElementByIdType(Document doc, String id) {
if (log.isLoggable(java.util.logging.Level.FINE)) if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "getElementByIdType() Search for ID " + id); log.log(java.util.logging.Level.FINE, "getElementByIdType() Search for ID " + id);
WeakHashMap elementMap = (WeakHashMap) docMap.get(doc); WeakHashMap elementMap;
synchronized (docMap) {
elementMap = (WeakHashMap) docMap.get(doc);
}
if (elementMap != null) { if (elementMap != null) {
WeakReference weakReference = (WeakReference) elementMap.get(id); WeakReference weakReference = (WeakReference) elementMap.get(id);
if (weakReference != null) { if (weakReference != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册