[JIRA] Created: (JXT-87) Code in AbstractSignableXMLObject etc unnecessarily calls NodeList which is thread-unsafe
anli.shundi@idp.protectnetwork.org (JIRA)
noreply at shibboleth.net
Thu Aug 9 23:27:06 EDT 2012
Code in AbstractSignableXMLObject etc unnecessarily calls NodeList which is thread-unsafe
-------------------------------------------------------------------------------------------
Key: JXT-87
URL: https://issues.shibboleth.net/jira/browse/JXT-87
Project: XMLTooling - Java
Issue Type: Bug
Reporter: anli.shundi at idp.protectnetwork.org
Assignee: Brent Putman
AbstractSignableXMLObject and other classes iterate over all DOM children by using the NodeList. This pattern is thread-unsafe since the DOM implementation will create a cache which will be inconsistent if accessible concurrently. Switching to the simpler getFirstChild() getNextSibling() is safer and even faster since no cache is created. The cache is useful for doing random access. All use-cases in XMLTooling seem to instead iterate over _all_ children.
New code in above class.
{code}
@Override
public boolean isSigned() {
Element domElement = getDOM();
if (domElement == null) {
return false;
}
for(Node childElement = domElement.getFirstChild(); childElement != null; childElement = childElement.getNextSibling()) {
if (childElement.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if (XMLConstants.XMLSIG_NS.equals(childElement.getNamespaceURI())
&& Signature.DEFAULT_ELEMENT_LOCAL_NAME.equals(childElement.getLocalName())) {
return true;
}
}
return false;
}
{code}
Similar pattern in {{AbstractXMLObjectUnmarshaller}} 's {{unmarshall(Element domElement)}} and {{XMLHelper}} 's
{code}getChildElements(Element)
getChildElementsByTagName(Element, String)
getChildElementsByTagNameNS(Element, String, String)
getElementContentAsQName(Element)
getFirstChildElement(Node)
rootNamespaces(Element, Element){code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the commits
mailing list